gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5868 - in GNUnet/src: applications/datastore applications/


From: gnunet
Subject: [GNUnet-SVN] r5868 - in GNUnet/src: applications/datastore applications/dht/module applications/dstore_mysql applications/dstore_sqlite applications/fragmentation applications/fs/fsui applications/fs/lib applications/identity applications/kvstore_sqlite applications/sqstore_mysql applications/sqstore_sqlite applications/tracekit include server transports transports/upnp util/cron
Date: Tue, 11 Dec 2007 23:42:27 -0700 (MST)

Author: grothoff
Date: 2007-12-11 23:42:26 -0700 (Tue, 11 Dec 2007)
New Revision: 5868

Modified:
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/dht/module/service.c
   GNUnet/src/applications/dstore_mysql/dstore_test.c
   GNUnet/src/applications/dstore_sqlite/dstore_test.c
   GNUnet/src/applications/fragmentation/fragmentationtest.c
   GNUnet/src/applications/fs/fsui/fsui.c
   GNUnet/src/applications/fs/lib/fslibtest.c
   GNUnet/src/applications/identity/identitytest.c
   GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c
   GNUnet/src/applications/sqstore_mysql/mysqltest.c
   GNUnet/src/applications/sqstore_mysql/mysqltest2.c
   GNUnet/src/applications/sqstore_mysql/mysqltest3.c
   GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
   GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c
   GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
   GNUnet/src/applications/tracekit/Makefile.am
   GNUnet/src/applications/tracekit/gnunet-tracekit.c
   GNUnet/src/include/Makefile.am
   GNUnet/src/include/gnunet_util_cron.h
   GNUnet/src/server/gnunet-peer-info.c
   GNUnet/src/server/gnunet-transport-check.c
   GNUnet/src/server/gnunet-update.c
   GNUnet/src/server/gnunetd.c
   GNUnet/src/transports/test.c
   GNUnet/src/transports/test_repeat.c
   GNUnet/src/transports/upnp/init.c
   GNUnet/src/util/cron/cron.c
   GNUnet/src/util/cron/crontest.c
   GNUnet/src/util/cron/timertest.c
Log:
missed renaming

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/datastore/datastore.c       2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -482,7 +482,7 @@
   GNUNET_free (fsdir);
 
   available = quota - sq->getSize ();
-  cron = cron_create (capi->ectx);
+  cron = GNUNET_cron_create (capi->ectx);
   GNUNET_cron_add_job (cron,
                        &cronMaintenance, 10 * GNUNET_CRON_SECONDS,
                        10 * GNUNET_CRON_SECONDS, NULL);

Modified: GNUnet/src/applications/dht/module/service.c
===================================================================
--- GNUnet/src/applications/dht/module/service.c        2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/dht/module/service.c        2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -165,7 +165,7 @@
 {
   static GNUNET_DHT_ServiceAPI api;
 
-  cron = cron_create (capi->ectx);
+  cron = GNUNET_cron_create (capi->ectx);
   GNUNET_cron_start (cron);
   if (GNUNET_OK != init_dht_store (1024 * 1024, capi))
     {

Modified: GNUnet/src/applications/dstore_mysql/dstore_test.c
===================================================================
--- GNUnet/src/applications/dstore_mysql/dstore_test.c  2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/dstore_mysql/dstore_test.c  2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -97,7 +97,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("dstore");
   if (api != NULL)

Modified: GNUnet/src/applications/dstore_sqlite/dstore_test.c
===================================================================
--- GNUnet/src/applications/dstore_sqlite/dstore_test.c 2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/dstore_sqlite/dstore_test.c 2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -99,7 +99,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("dstore");
   if (api != NULL)

Modified: GNUnet/src/applications/fragmentation/fragmentationtest.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentationtest.c   2007-12-12 
05:32:31 UTC (rev 5867)
+++ GNUnet/src/applications/fragmentation/fragmentationtest.c   2007-12-12 
06:42:26 UTC (rev 5868)
@@ -393,7 +393,7 @@
   GNUNET_CoreAPIForPlugins capi;
 
   memset (&capi, 0, sizeof (GNUNET_CoreAPIForPlugins));
-  capi.cron = cron_create (NULL);
+  capi.cron = GNUNET_cron_create (NULL);
   capi.injectMessage = &handleHelper;
   capi.requestService = &requestService;
   capi.registerHandler = &registerp2pHandler;

Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c      2007-12-12 05:32:31 UTC (rev 
5867)
+++ GNUnet/src/applications/fs/fsui/fsui.c      2007-12-12 06:42:26 UTC (rev 
5868)
@@ -291,7 +291,7 @@
     }
 
   /* 3) restart processing */
-  ret->cron = cron_create (ectx);
+  ret->cron = GNUNET_cron_create (ectx);
   /* 3a) resume downloads */
   GNUNET_cron_add_job (ret->cron,
                        &updateDownloadThreads, 0, GNUNET_FSUI_UDT_FREQUENCY,

Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c  2007-12-12 05:32:31 UTC (rev 
5867)
+++ GNUnet/src/applications/fs/lib/fslibtest.c  2007-12-12 06:42:26 UTC (rev 
5868)
@@ -224,7 +224,7 @@
       return -1;
     }
   now = GNUNET_get_time ();
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
 #if START_DAEMON
   daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
   GNUNET_GE_ASSERT (NULL, daemon > 0);

Modified: GNUnet/src/applications/identity/identitytest.c
===================================================================
--- GNUnet/src/applications/identity/identitytest.c     2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/identity/identitytest.c     2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -140,7 +140,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   err = 0;
   if (GNUNET_OK != runTest ())

Modified: GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c      2007-12-12 
05:32:31 UTC (rev 5867)
+++ GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c      2007-12-12 
06:42:26 UTC (rev 5868)
@@ -87,7 +87,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("kvstore_sqlite");
   if (api != NULL)

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c   2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c   2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -262,7 +262,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("sqstore");
   if (api != NULL)

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest2.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest2.c  2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest2.c  2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -258,7 +258,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("sqstore");
   if (api != NULL)

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest3.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest3.c  2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest3.c  2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -182,7 +182,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("sqstore");
   if (api != NULL)

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -262,7 +262,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("sqstore");
   if (api != NULL)

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c        2007-12-12 
05:32:31 UTC (rev 5867)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c        2007-12-12 
06:42:26 UTC (rev 5868)
@@ -258,7 +258,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("sqstore");
   if (api != NULL)

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c        2007-12-12 
05:32:31 UTC (rev 5867)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c        2007-12-12 
06:42:26 UTC (rev 5868)
@@ -182,7 +182,7 @@
       GNUNET_GC_free (cfg);
       return -1;
     }
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   api = requestService ("sqstore");
   if (api != NULL)

Modified: GNUnet/src/applications/tracekit/Makefile.am
===================================================================
--- GNUnet/src/applications/tracekit/Makefile.am        2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/tracekit/Makefile.am        2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -11,12 +11,18 @@
 plugin_LTLIBRARIES = \
   libgnunetmodule_tracekit.la
 
+lib_LTLIBRARIES = \
+  libgnunettracekit_api.la
 
 gnunet_tracekit_SOURCES = \
   gnunet-tracekit.c \
   tracekit.h
 
+gnunet_tracekit_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/applications/tracekit/libgnunettracekit_api.la 
 
+
 libgnunetmodule_tracekit_la_SOURCES = \
   tracekit.c \
   tracekit.h
@@ -26,3 +32,19 @@
 
 libgnunetmodule_tracekit_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
+
+libgnunettracekit_api_la_SOURCES = \
+  clientapi.c 
+libgnunettracekit_api_la_LIBADD = \
+  $(top_builddir)/src/util/libgnunetutil.la 
+
+check_PROGRAMS = \
+  tracekittest
+
+tracekittest_SOURCES = \
+  tracekittest.c 
+tracekittest_LDADD = \
+  $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
+  $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
+  $(top_builddir)/src/applications/tracekit/libgnunettracekit_api.la \
+  $(top_builddir)/src/util/libgnunetutil.la 

Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/gnunet-tracekit.c  2007-12-12 05:32:31 UTC 
(rev 5867)
+++ GNUnet/src/applications/tracekit/gnunet-tracekit.c  2007-12-12 06:42:26 UTC 
(rev 5868)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2006 Christian Grothoff (and other contributing 
authors)
+     (C) 2001, 2002, 2004, 2006, 2007 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
@@ -28,9 +28,13 @@
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
 #include "gnunet_util.h"
+#include "gnunet_tracekit_lib.h"
 #include "tracekit.h"
 
-static struct GNUNET_Semaphore *doneSem;
+struct SeenRecord {
+  GNUNET_PeerIdentity src;
+  GNUNET_PeerIdentity dst;
+};
 
 static char *cfgFilename = GNUNET_DEFAULT_CLIENT_CONFIG_FILE;
 
@@ -38,193 +42,259 @@
 
 static struct GNUNET_GC_Configuration *cfg;
 
+static unsigned int priority = 0;
+
+static unsigned int depth = 5;
+
+static unsigned int format = 0;
+
+static unsigned int delay = 300;
+
+static struct SeenRecord * seen;
+
+static unsigned int count;
+
+static int
+check_seen(const GNUNET_PeerIdentity * src,
+          const GNUNET_PeerIdentity * dst) {
+  static GNUNET_PeerIdentity null_peer;
+  unsigned int j;
+
+  if (dst == NULL)
+    dst = &null_peer;
+  for (j = 0; j < count; j++)
+    if ( (0 == memcmp (src,
+                      &seen[j].src,
+                      sizeof (GNUNET_HashCode)) ) &&
+        (0 == memcmp (dst,
+                      &seen[j].dst,
+                      sizeof (GNUNET_HashCode) ) ) )
+      return GNUNET_YES;
+  GNUNET_array_grow(seen,
+                   count,
+                   count+1);
+  seen[count-1].src = *src;
+  seen[count-1].dst = *dst;
+  return GNUNET_NO;
+}
+
 /**
- * All gnunet-tracekit command line options
+ * Generate a human-readable report.
+ *
+ * @param reporter identity of the peer reporting a connection
+ * @param link identity of another peer that the reporting peer
+ *             is reported to be connected to, or NULL if the
+ *             peer is reporting to have no connections at all
+ * @return GNUNET_OK to continue data gathering,
+ *         GNUNET_SYSERR to abort
  */
-static struct GNUNET_CommandLineOption gnunettracekitOptions[] = {
-  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
-  {'D', "depth", "DEPTH",
-   gettext_noop ("probe network to the given DEPTH"), 1,
-   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:HOPS"},
-  {'F', "format", "FORMAT",
-   gettext_noop
-   ("specify output format; 0 for human readable output, 1 for dot, 2 for 
vcg"),
-   1,
-   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:FORMAT"},
-  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Start GNUnet transport 
benchmarking tool.")), /* -h */
-  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
-  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
-  {'P', "priority", "PRIO",
-   gettext_noop ("use PRIO for the priority of the trace request"), 1,
-   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:PRIORITY"},
-  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
-  {'W', "wait", "DELAY",
-   gettext_noop ("wait DELAY seconds for replies"), 1,
-   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:WAIT"},
-  GNUNET_COMMAND_LINE_OPTION_END,
-};
+static int
+human_readable(void * unused,
+              const GNUNET_PeerIdentity * reporter,
+              const GNUNET_PeerIdentity * link) {
+  GNUNET_EncName src;
+  GNUNET_EncName dst;
 
-static unsigned int
-getConfigurationInt (const char *sec, const char *opt, unsigned int max)
-{
-  unsigned long long val;
+  if (check_seen(reporter, link))
+    return GNUNET_OK;
+  
+  GNUNET_hash_to_enc (&reporter->hashPubKey, &src);  
+  if (link != NULL) 
+    {
+      GNUNET_hash_to_enc (&link->hashPubKey, &dst);
+      fprintf(stdout,
+             _("`%s' connected to `%s'.\n"),
+             (const char*) &src,
+             (const char*) &dst);
+    }
+  else 
+    {
+      fprintf(stdout,
+             _("`%s' is not connected to any peer.\n"),
+             (const char*) &src);
+    }
+  return GNUNET_OK;
+}
 
-  GNUNET_GC_get_configuration_value_number (cfg, sec, opt, 0, max, 0, &val);
-  return (unsigned int) val;
+/**
+ * Generate dot-format.
+ *
+ * @param reporter identity of the peer reporting a connection
+ * @param link identity of another peer that the reporting peer
+ *             is reported to be connected to, or NULL if the
+ *             peer is reporting to have no connections at all
+ * @return GNUNET_OK to continue data gathering,
+ *         GNUNET_SYSERR to abort
+ */
+static int
+dot_format(void * unused,
+          const GNUNET_PeerIdentity * reporter,
+          const GNUNET_PeerIdentity * link) {
+  GNUNET_EncName src;
+  GNUNET_EncName dst;
+
+  if (check_seen(reporter, link))
+    return GNUNET_OK;
+  GNUNET_hash_to_enc (&reporter->hashPubKey, &src);  
+  if (link != NULL)
+    {
+      GNUNET_hash_to_enc (&link->hashPubKey, &dst);
+      printf ("  \"%.*s\" -> \"%.*s\";\n",
+             4, (char *) &src, 4, (char *) &dst);
+    } 
+  else
+    {
+      printf ("  %.*s;\n", 4, (char *) &src);
+    }
+  
+  return GNUNET_OK;
 }
 
-static void
-run_shutdown (void *unused)
-{
-  GNUNET_shutdown_initiate ();
+/**
+ * Generate vcg-format.
+ *
+ * @param reporter identity of the peer reporting a connection
+ * @param link identity of another peer that the reporting peer
+ *             is reported to be connected to, or NULL if the
+ *             peer is reporting to have no connections at all
+ * @return GNUNET_OK to continue data gathering,
+ *         GNUNET_SYSERR to abort
+ */
+static int
+vcg_format(void * unused,
+          const GNUNET_PeerIdentity * reporter,
+          const GNUNET_PeerIdentity * link) {
+  GNUNET_EncName src;
+  GNUNET_EncName dst;
+
+  if (check_seen(reporter, link))
+    return GNUNET_OK;
+  GNUNET_hash_to_enc (&reporter->hashPubKey, &src);  
+  if (link != NULL)
+    {
+      GNUNET_hash_to_enc (&link->hashPubKey, &dst);
+      printf
+       ("\tedge: { sourcename: \"%s\" targetname: \"%s\" }\n",
+        (char *) &src, (char *) &dst);
+    }
+  else 
+    {
+      /* deferred -- vcg needs all node data in one line */
+    }
+  return GNUNET_OK;
 }
 
+
 static void *
-receiveThread (void *cls)
+process (void *cls)
 {
+  static GNUNET_PeerIdentity null_peer;
+  GNUNET_PeerIdentity * current;
   struct GNUNET_ClientServerConnection *sock = cls;
-  CS_tracekit_reply_MESSAGE *buffer;
-  unsigned long long format;
-  GNUNET_PeerIdentity *peersSeen;
-  unsigned int psCount;
-  unsigned int psSize;
-  GNUNET_PeerIdentity *peersResponding;
-  unsigned int prCount;
-  unsigned int prSize;
-  int i;
-  int j;
-  int match;
+  GNUNET_TRACEKIT_ReportCallback report;
+  GNUNET_EncName enc;
+  unsigned int i;
+  unsigned int j;
+  int is_source;
+  int is_first;
 
-  psCount = 0;
-  psSize = 1;
-  peersSeen = GNUNET_malloc (psSize * sizeof (GNUNET_PeerIdentity));
-  prCount = 0;
-  prSize = 1;
-  peersResponding = GNUNET_malloc (prSize * sizeof (GNUNET_PeerIdentity));
-  buffer = GNUNET_malloc (GNUNET_MAX_BUFFER_SIZE);
-  if (-1 ==
-      GNUNET_GC_get_configuration_value_number (cfg,
-                                                "GNUNET-TRACEKIT",
-                                                "FORMAT", 0, 2, 0, &format))
+  report = NULL;
+  switch (format) 
     {
-      printf (_("Format specification invalid. "
-                "Use 0 for user-readable, 1 for dot, 2 for vcg.\n"));
-      GNUNET_semaphore_up (doneSem);
-      GNUNET_free (peersResponding);
-      GNUNET_free (peersSeen);
-      GNUNET_free (buffer);
-      return NULL;
+    case 0:
+      report = &human_readable;
+      break;
+    case 1:
+    printf ("digraph G {\n");
+      report = &dot_format;
+      break;
+    case 2:
+      report = &vcg_format;
+      printf ("graph: {\n");
+      break;
+    default:
+      GNUNET_GE_BREAK(NULL, 0);      
     }
-  if (format == 1)
-    printf ("digraph G {\n");
-  if (format == 2)
-    printf ("graph: {\n");
-  while (GNUNET_OK ==
-         GNUNET_client_connection_read (sock,
-                                        (GNUNET_MessageHeader **) & buffer))
+  GNUNET_TRACEKIT_run(sock,
+                     depth,
+                     priority,
+                     report,
+                     NULL);
+  /* final processing loop */
+  for (i=0;i<count*2;i++) 
     {
-      int count;
-      GNUNET_EncName enc;
-
-      count =
-        ntohs (buffer->header.size) - sizeof (CS_tracekit_reply_MESSAGE);
-      if (count < 0)
-        {
-          GNUNET_GE_BREAK (ectx, 0);
-          break;                /* faulty reply */
-        }
-      GNUNET_hash_to_enc (&buffer->responderId.hashPubKey, &enc);
-      match = GNUNET_NO;
-      for (j = 0; j < prCount; j++)
-        if (0 == memcmp (&buffer->responderId.hashPubKey,
-                         &peersResponding[j].hashPubKey,
-                         sizeof (GNUNET_HashCode)))
-          match = GNUNET_YES;
-      if (match == GNUNET_NO)
-        {
-          if (prCount == prSize)
-            GNUNET_array_grow (peersResponding, prSize, prSize * 2);
-          memcpy (&peersResponding[prCount++],
-                  &buffer->responderId.hashPubKey,
-                  sizeof (GNUNET_PeerIdentity));
-        }
-      count = count / sizeof (GNUNET_PeerIdentity);
-      if (ntohs (buffer->header.size) !=
-          sizeof (CS_tracekit_reply_MESSAGE) +
-          count * sizeof (GNUNET_PeerIdentity))
-        {
-          GNUNET_GE_BREAK (ectx, 0);
-          break;
-        }
-      if (count == 0)
-        {
-          switch (format)
-            {
-            case 0:
-              printf (_("`%s' is not connected to any peer.\n"),
-                      (char *) &enc);
-              break;
-            case 1:
-              printf ("  %.*s;\n", 4, (char *) &enc);
-              break;
-            case 2:
-              /* deferred -- vcg needs all node data in one line */
-              break;
-            }
-        }
+      if (0 == i % 2)
+       current = &seen[i / 2].src;
       else
-        {
-          GNUNET_EncName other;
+       current = &seen[i / 2].dst;
+      if (0 == memcmp(current,
+                     &null_peer,
+                     sizeof(GNUNET_PeerIdentity)) )
+       continue;
+      is_first = GNUNET_YES;
+      for (j=0;j<count*2;j++)
+       if (0 == memcmp(current,
+                       (0 == i % 2) ? &seen[i/2].src : &seen[i/2].dst,
+                       sizeof(GNUNET_PeerIdentity)) )
+         {
+           is_first = GNUNET_NO;
+           break;
+         }
+      if (is_first != GNUNET_YES)
+       continue; /* only each peer once */
+      is_source = GNUNET_NO;
+      for (j=0;j<count;j++)
+       {
+         if (0 == memcmp(current,
+                         &seen[i].src,
+                         sizeof(GNUNET_PeerIdentity)) ) 
+           {
+             is_source = GNUNET_YES;        
+             break;
+           }
+       }
+      switch (format) 
+       {
+       case 0:
+         break;
+       case 1:
+         if (is_source == GNUNET_NO) 
+           {         
+             printf ("  \"%.*s\" [style=filled,color=\".7 .3 1.0\"];\n",
+                     4, (char *) &enc);
+           }
+         break;
+       case 2:
+         if (is_source == GNUNET_NO) 
+           {
+             printf
+                ("\tnode: { title: \"%s\" label: \"%.*s\" shape: \"ellipse\" 
}\n",
+                 (char *) &enc, 4, (char *) &enc);
+           }
+         else 
+           {
+              printf ("\tnode: { title: \"%s\" label: \"%.*s\" }\n",
+                      (char *) &enc, 4, (char *) &enc);
+           }
+         break;          
+       }
+    }
+  /* close syntax */
+  switch (format) 
+    {
+    case 0:
+      break;
+    case 1:
+      printf ("}\n");
+      break;
+    case 2:
+      printf ("}\n");
+      break;
+    }
+  return NULL;
+}
 
-          for (i = 0; i < count; i++)
-            {
-              match = GNUNET_NO;
-              for (j = 0; j < psCount; j++)
-                if (0 ==
-                    memcmp (&
-                            ((CS_tracekit_reply_MESSAGE_GENERIC *)
-                             buffer)->peerList[i].hashPubKey,
-                            &peersSeen[j].hashPubKey,
-                            sizeof (GNUNET_HashCode)))
-                  match = GNUNET_YES;
-              if (match == GNUNET_NO)
-                {
-                  if (psCount == psSize)
-                    GNUNET_array_grow (peersSeen, psSize, psSize * 2);
-                  memcpy (&peersSeen[psCount++],
-                          &((CS_tracekit_reply_MESSAGE_GENERIC *)
-                            buffer)->peerList[i].hashPubKey,
-                          sizeof (GNUNET_PeerIdentity));
-                }
-
-              GNUNET_hash_to_enc (&
-                                  ((CS_tracekit_reply_MESSAGE_GENERIC
-                                    *) buffer)->peerList[i].hashPubKey,
-                                  &other);
-              switch (format)
-                {
-                case 0:
-                  printf (_("`%s' connected to `%s'.\n"),
-                          (char *) &enc, (char *) &other);
-                  break;
-                case 1:        /* dot */
-                  printf ("  \"%.*s\" -> \"%.*s\";\n",
-                          4, (char *) &enc, 4, (char *) &other);
-                  break;
-                case 2:        /* vcg */
-                  printf
-                    ("\tedge: { sourcename: \"%s\" targetname: \"%s\" }\n",
-                     (char *) &enc, (char *) &other);
-                  break;
-                default:       /* undef */
-                  printf (_("Format specification invalid. "
-                            "Use 0 for user-readable, 1 for dot\n"));
-                  break;
-                }
-            }
-        }
-    }
-  GNUNET_free (buffer);
+#if 0
   for (i = 0; i < psCount; i++)
     {
       GNUNET_EncName enc;
@@ -242,12 +312,7 @@
           GNUNET_hash_to_enc (&peersSeen[i].hashPubKey, &enc);
           switch (format)
             {
-            case 0:
-              printf (_("Peer `%s' did not report back.\n"), (char *) &enc);
-              break;
             case 1:
-              printf ("  \"%.*s\" [style=filled,color=\".7 .3 1.0\"];\n",
-                      4, (char *) &enc);
               break;
             case 2:
               printf
@@ -263,9 +328,6 @@
           switch (format)
             {
             case 2:
-              GNUNET_hash_to_enc (&peersSeen[i].hashPubKey, &enc);
-              printf ("\tnode: { title: \"%s\" label: \"%.*s\" }\n",
-                      (char *) &enc, 4, (char *) &enc);
               break;
             default:
               break;
@@ -283,14 +345,39 @@
           break;
         }
     }
-  if (format == 1)
-    printf ("}\n");
-  if (format == 2)
-    printf ("}\n");
-  GNUNET_semaphore_up (doneSem);
-  GNUNET_free (peersResponding);
-  GNUNET_free (peersSeen);
-  return NULL;
+#endif
+
+
+/**
+ * All gnunet-tracekit command line options
+ */
+static struct GNUNET_CommandLineOption gnunettracekitOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
+  {'D', "depth", "DEPTH",
+   gettext_noop ("probe network to the given DEPTH"), 1,
+   &GNUNET_getopt_configure_set_uint, &depth},
+  {'F', "format", "FORMAT",
+   gettext_noop
+   ("specify output format; 0 for human readable output, 1 for dot, 2 for 
vcg"),
+   1,
+   &GNUNET_getopt_configure_set_uint, &format} ,
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Start GNUnet transport 
benchmarking tool.")), /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
+  {'P', "priority", "PRIORITY",
+   gettext_noop ("use PRIORITY for the priority of the trace request"), 1,
+   &GNUNET_getopt_configure_set_uint, &priority, },
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  {'W', "wait", "DELAY",
+   gettext_noop ("wait DELAY seconds for replies"), 1,
+   &GNUNET_getopt_configure_set_uint, &delay },
+  GNUNET_COMMAND_LINE_OPTION_END,
+};
+
+static void
+run_shutdown (void *unused)
+{
+  GNUNET_shutdown_initiate ();
 }
 
 /**
@@ -302,23 +389,26 @@
 main (int argc, char *const *argv)
 {
   struct GNUNET_ClientServerConnection *sock;
-  struct GNUNET_ThreadHandle *messageReceiveThread;
-  void *unused;
-  CS_tracekit_probe_MESSAGE probe;
-  int sleepTime;
+  struct GNUNET_ThreadHandle * myThread;
   struct GNUNET_GE_Context *ectx;
   struct GNUNET_CronManager *cron;
-  int res;
+  void * unused;
 
-  res = GNUNET_init (argc,
-                     argv,
-                     "gnunet-tracekit",
-                     &cfgFilename, gnunettracekitOptions, &ectx, &cfg);
-  if (res == -1)
+  if (-1 ==  GNUNET_init (argc,
+                         argv,
+                         "gnunet-tracekit",
+                         &cfgFilename, gnunettracekitOptions, &ectx, &cfg)) 
     {
       GNUNET_fini (ectx, cfg);
       return -1;
     }
+  if (format > 2) 
+    {
+      printf (_("Format specification invalid. "
+               "Use 0 for user-readable, 1 for dot, 2 for vcg.\n"));
+      return -1;
+    }
+
   sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
@@ -326,43 +416,23 @@
       GNUNET_fini (ectx, cfg);
       return 1;
     }
-
-  doneSem = GNUNET_semaphore_create (0);
-  messageReceiveThread =
-    GNUNET_thread_create (&receiveThread, sock, 128 * 1024);
-  if (messageReceiveThread == NULL)
+  myThread =
+    GNUNET_thread_create (&process, sock, 128 * 1024);
+  if (myThread == NULL)
     GNUNET_GE_DIE_STRERROR (ectx,
                             GNUNET_GE_FATAL | GNUNET_GE_IMMEDIATE |
                             GNUNET_GE_ADMIN, "pthread_create");
-
-  probe.header.size = htons (sizeof (CS_tracekit_probe_MESSAGE));
-  probe.header.type = htons (GNUNET_CS_PROTO_TRACEKIT_PROBE);
-  probe.hops
-    = htonl (getConfigurationInt ("GNUNET-TRACEKIT", "HOPS", 0xFFFFFFFF));
-  probe.priority
-    = htonl (getConfigurationInt ("GNUNET-TRACEKIT", "PRIORITY", 0xFFFFFFFF));
-  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &probe.header))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _("Could not send request to gnunetd.\n"));
-      return -1;
-    }
-  cron = cron_create (ectx);
+  cron = GNUNET_cron_create (ectx);
   GNUNET_cron_start (cron);
-  sleepTime = getConfigurationInt ("GNUNET-TRACEKIT", "WAIT", 0xFFFFFFFF);
-  if (sleepTime == 0)
-    sleepTime = 5;
-  GNUNET_cron_add_job (cron, &run_shutdown, GNUNET_CRON_SECONDS * sleepTime,
+  GNUNET_cron_add_job (cron, &run_shutdown, GNUNET_CRON_SECONDS * delay,
                        0, NULL);
   GNUNET_shutdown_wait_for ();
   GNUNET_client_connection_close_forever (sock);
-  GNUNET_semaphore_down (doneSem, GNUNET_YES);
-  GNUNET_semaphore_destroy (doneSem);
-  GNUNET_thread_join (messageReceiveThread, &unused);
+  GNUNET_thread_join (myThread, &unused);
   GNUNET_client_connection_destroy (sock);
   GNUNET_cron_stop (cron);
   GNUNET_cron_destroy (cron);
+  GNUNET_array_grow(seen, count, 0);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am      2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/include/Makefile.am      2007-12-12 06:42:26 UTC (rev 5868)
@@ -44,6 +44,7 @@
   gnunet_stats_service.h \
   gnunet_testing_lib.h \
   gnunet_topology_service.h \
+  gnunet_tracekit_lib.h \
   gnunet_traffic_lib.h \
   gnunet_traffic_service.h \
   gnunet_transport.h \

Modified: GNUnet/src/include/gnunet_util_cron.h
===================================================================
--- GNUnet/src/include/gnunet_util_cron.h       2007-12-12 05:32:31 UTC (rev 
5867)
+++ GNUnet/src/include/gnunet_util_cron.h       2007-12-12 06:42:26 UTC (rev 
5868)
@@ -47,7 +47,7 @@
 
 struct GNUNET_CronManager;
 
-struct GNUNET_CronManager *cron_create (struct GNUNET_GE_Context *ectx);
+struct GNUNET_CronManager * GNUNET_cron_create (struct GNUNET_GE_Context 
*ectx);
 
 void GNUNET_cron_destroy (struct GNUNET_CronManager *mgr);
 

Modified: GNUnet/src/server/gnunet-peer-info.c
===================================================================
--- GNUnet/src/server/gnunet-peer-info.c        2007-12-12 05:32:31 UTC (rev 
5867)
+++ GNUnet/src/server/gnunet-peer-info.c        2007-12-12 06:42:26 UTC (rev 
5868)
@@ -183,7 +183,7 @@
                                                                    "TCPSERVER",
                                                                    "DISABLE",
                                                                    "YES"));
-  cron = cron_create (ectx);
+  cron = GNUNET_cron_create (ectx);
   initCore (ectx, cfg, cron, NULL);
   identity = requestService ("identity");
   transport = requestService ("transport");

Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c  2007-12-12 05:32:31 UTC (rev 
5867)
+++ GNUnet/src/server/gnunet-transport-check.c  2007-12-12 06:42:26 UTC (rev 
5868)
@@ -455,7 +455,7 @@
       GNUNET_GC_set_configuration_value_string (cfg, ectx, "HTTP",
                                                 "BLACKLIST", "");
     }
-  cron = cron_create (ectx);
+  cron = GNUNET_cron_create (ectx);
   if (GNUNET_OK != initCore (ectx, cfg, cron, NULL))
     {
       GNUNET_free (expectedValue);

Modified: GNUnet/src/server/gnunet-update.c
===================================================================
--- GNUnet/src/server/gnunet-update.c   2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/server/gnunet-update.c   2007-12-12 06:42:26 UTC (rev 5868)
@@ -214,7 +214,7 @@
                  "Failed to write configuration with updated F2F 
configuration.\n");
     }
   GNUNET_free (topo);
-  cron = cron_create (ectx);
+  cron = GNUNET_cron_create (ectx);
   if (initCore (ectx, cfg, cron, NULL) != GNUNET_OK)
     {
       GNUNET_GE_LOG (ectx,

Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/server/gnunetd.c 2007-12-12 06:42:26 UTC (rev 5868)
@@ -109,7 +109,7 @@
         GNUNET_pid_file_delete (ectx, cfg);
       return GNUNET_SYSERR;
     }
-  cron = cron_create (ectx);
+  cron = GNUNET_cron_create (ectx);
   GNUNET_GE_ASSERT (ectx, cron != NULL);
 #ifndef WINDOWS
   shc_hup = GNUNET_signal_handler_install (SIGHUP, &reread_config);

Modified: GNUnet/src/transports/test.c
===================================================================
--- GNUnet/src/transports/test.c        2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/transports/test.c        2007-12-12 06:42:26 UTC (rev 5868)
@@ -245,7 +245,7 @@
       GNUNET_plugin_unload (plugin);
       goto cleanup;
     }
-  api.cron = cron_create (api.ectx);
+  api.cron = GNUNET_cron_create (api.ectx);
   api.myIdentity = &me;
   api.receive = &receive;
   api.requestService = &requestService;

Modified: GNUnet/src/transports/test_repeat.c
===================================================================
--- GNUnet/src/transports/test_repeat.c 2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/transports/test_repeat.c 2007-12-12 06:42:26 UTC (rev 5868)
@@ -248,7 +248,7 @@
       GNUNET_plugin_unload (plugin);
       goto cleanup;
     }
-  api.cron = cron_create (api.ectx);
+  api.cron = GNUNET_cron_create (api.ectx);
   api.myIdentity = &me;
   api.receive = &receive;
   api.requestService = &requestService;

Modified: GNUnet/src/transports/upnp/init.c
===================================================================
--- GNUnet/src/transports/upnp/init.c   2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/transports/upnp/init.c   2007-12-12 06:42:26 UTC (rev 5868)
@@ -157,7 +157,7 @@
 
   ectx = capi->ectx;
   cfg = capi->cfg;
-  cron = cron_create (ectx);
+  cron = GNUNET_cron_create (ectx);
   lock = GNUNET_mutex_create (GNUNET_NO);
   GNUNET_cron_start (cron);
   GNUNET_cron_add_job (cron, &discover, 0, 5 * GNUNET_CRON_MINUTES, NULL);

Modified: GNUnet/src/util/cron/cron.c
===================================================================
--- GNUnet/src/util/cron/cron.c 2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/util/cron/cron.c 2007-12-12 06:42:26 UTC (rev 5868)
@@ -180,7 +180,7 @@
 
 
 struct GNUNET_CronManager *
-cron_create (struct GNUNET_GE_Context *ectx)
+GNUNET_cron_create (struct GNUNET_GE_Context *ectx)
 {
   struct GNUNET_CronManager *cron;
   unsigned int i;

Modified: GNUnet/src/util/cron/crontest.c
===================================================================
--- GNUnet/src/util/cron/crontest.c     2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/util/cron/crontest.c     2007-12-12 06:42:26 UTC (rev 5868)
@@ -119,7 +119,7 @@
 {
   int failureCount = 0;
 
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   GNUNET_cron_start (cron);
   failureCount += testCron ();
   failureCount += testDelCron ();

Modified: GNUnet/src/util/cron/timertest.c
===================================================================
--- GNUnet/src/util/cron/timertest.c    2007-12-12 05:32:31 UTC (rev 5867)
+++ GNUnet/src/util/cron/timertest.c    2007-12-12 06:42:26 UTC (rev 5868)
@@ -89,7 +89,7 @@
 {
   int failureCount = 0;
 
-  cron = cron_create (NULL);
+  cron = GNUNET_cron_create (NULL);
   GNUNET_cron_start (cron);
   failureCount += check ();
   GNUNET_cron_stop (cron);





reply via email to

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