gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33034 - in gnunet: doc/man po src/core


From: gnunet
Subject: [GNUnet-SVN] r33034 - in gnunet: doc/man po src/core
Date: Fri, 11 Apr 2014 14:17:29 +0200

Author: grothoff
Date: 2014-04-11 14:17:29 +0200 (Fri, 11 Apr 2014)
New Revision: 33034

Modified:
   gnunet/doc/man/gnunet-core.1
   gnunet/po/POTFILES.in
   gnunet/src/core/gnunet-core.c
Log:
-improve/simplify gnunet-core tool and update man page

Modified: gnunet/doc/man/gnunet-core.1
===================================================================
--- gnunet/doc/man/gnunet-core.1        2014-04-11 12:08:14 UTC (rev 33033)
+++ gnunet/doc/man/gnunet-core.1        2014-04-11 12:17:29 UTC (rev 33034)
@@ -1,6 +1,6 @@
-.TH gnunet\-core "1" "1 Apr 2012" "GNUnet"
+.TH gnunet\-core "1" "11 Apr 2014" "GNUnet"
 .SH NAME
-gnunet\-core \- measure and control the core subsystem
+gnunet\-core \- monitor CORE subsystem
 
 .SH SYNOPSIS
 .B gnunet\-core
@@ -8,7 +8,7 @@
 .SH DESCRIPTION
 .PP
 
-gnunet\-core is a tool to access various functions of GNUnet's core subsystem 
from the command\-line.  The only function right now is to list the peers that 
are directly connected to this peer (with successful cryptographic handshake).
+gnunet\-core is a tool to access various functions of GNUnet's core subsystem 
from the command\-line.  The only function right now is to monitor the status 
of peers known to the CORE service.
 
 .TP
 \fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR
@@ -20,6 +20,9 @@
 \fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
 Change the loglevel.  Possible values for LOGLEVEL are ERROR, WARNING, INFO 
and DEBUG.
 .TP
+\fB\-m\fR, \fB\-\-monitor\fR
+in monitor mode, gnunet\-core will continuously print the connection status, 
instead of giving just a snapshot
+.TP
 \fB\-v\fR, \fB\-\-version\fR
 print the version number
 .TP

Modified: gnunet/po/POTFILES.in
===================================================================
--- gnunet/po/POTFILES.in       2014-04-11 12:08:14 UTC (rev 33033)
+++ gnunet/po/POTFILES.in       2014-04-11 12:17:29 UTC (rev 33034)
@@ -182,6 +182,7 @@
 src/identity/identity_api_lookup.c
 src/mesh/gnunet-mesh.c
 src/mesh/gnunet-mesh-profiler.c
+src/mesh/gnunet-mesh-profiler.c
 src/mesh/gnunet-service-mesh.c
 src/mesh/gnunet-service-mesh_channel.c
 src/mesh/gnunet-service-mesh_connection.c

Modified: gnunet/src/core/gnunet-core.c
===================================================================
--- gnunet/src/core/gnunet-core.c       2014-04-11 12:08:14 UTC (rev 33033)
+++ gnunet/src/core/gnunet-core.c       2014-04-11 12:17:29 UTC (rev 33034)
@@ -20,7 +20,7 @@
 
 /**
  * @file core/gnunet-core.c
- * @brief Print information about other known _connected_ peers.
+ * @brief Print information about other peers known to CORE.
  * @author Nathan Evans
  */
 #include "platform.h"
@@ -34,11 +34,6 @@
 static int monitor_connections;
 
 /**
- * Current number of connections in monitor mode
- */
-// static unsigned int monitor_connections_counter;
-
-/**
  * Handle to the CORE monitor.
  */
 static struct GNUNET_CORE_MonitorHandle *mh;
@@ -48,7 +43,7 @@
  * Task run in monitor mode when the user presses CTRL-C to abort.
  * Stops monitoring activity.
  *
- * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *'
+ * @param cls NULL
  * @param tc scheduler context
  */
 static void
@@ -80,53 +75,54 @@
 {
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
   const char *now_str;
+  const char *state_str;
 
-  if ( (NULL == peer) &&
+  if ( ( (NULL == peer) ||
+         (GNUNET_CORE_KX_ITERATION_FINISHED == state) ) &&
        (GNUNET_NO == monitor_connections) )
   {
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  now_str = GNUNET_STRINGS_absolute_time_to_string (now);
-  FPRINTF (stdout,
-           _("%24s: %-17s %d %4s\n"),
-           now_str,
-           "FIXME",
-           state,
-           GNUNET_i2s (peer));
-}
 
-
-/**
- * Function called with the result of the check if the CORE
- * service is running.
- *
- * @param cls closure with our configuration
- * @param result #GNUNET_YES if CORE is running
- */
-static void
-testservice_task (void *cls,
-                  int result)
-{
-  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
-
-  if (GNUNET_OK != result)
+  switch (state)
   {
-    FPRINTF (stderr, _("Service `%s' is not running\n"), "core");
+  case GNUNET_CORE_KX_STATE_DOWN:
+    /* should never happen, as we immediately send the key */
+    state_str = _("fresh connection");
+    break;
+  case GNUNET_CORE_KX_STATE_KEY_SENT:
+    state_str = _("key sent");
+    break;
+  case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
+    state_str = _("key received");
+    break;
+  case GNUNET_CORE_KX_STATE_UP:
+    state_str = _("connection established");
+    break;
+  case GNUNET_CORE_KX_STATE_REKEY_SENT:
+    state_str = _("rekeying");
+    break;
+  case GNUNET_CORE_KX_PEER_DISCONNECT:
+    state_str = _("disconnected");
+    break;
+  case GNUNET_CORE_KX_ITERATION_FINISHED:
     return;
-  }
-
-  mh = GNUNET_CORE_monitor_start (cfg,
-                                  &monitor_cb,
-                                  NULL);
-  if (NULL == mh)
-  {
-    GNUNET_SCHEDULER_add_now (shutdown_task, NULL);
-    fprintf (stderr, ("Failed to connect to CORE service!\n"));
+  case GNUNET_CORE_KX_CORE_DISCONNECT:
+    FPRINTF (stderr,
+             "%s\n",
+             _("Connection to CORE service lost (reconnecting)"));
     return;
+  default:
+    state_str = _("unknown state");
+    break;
   }
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &shutdown_task, NULL);
+  now_str = GNUNET_STRINGS_absolute_time_to_string (now);
+  FPRINTF (stdout,
+           _("%24s: %-17s %4s\n"),
+           now_str,
+           state_str,
+           GNUNET_i2s (peer));
 }
 
 
@@ -149,9 +145,18 @@
              args[0]);
     return;
   }
-  GNUNET_CLIENT_service_test ("core", cfg,
-                              GNUNET_TIME_UNIT_SECONDS,
-                              &testservice_task, (void *) cfg);
+  mh = GNUNET_CORE_monitor_start (cfg,
+                                  &monitor_cb,
+                                  NULL);
+  if (NULL == mh)
+  {
+    FPRINTF (stderr,
+             "%s",
+             _("Failed to connect to CORE service!\n"));
+    return;
+  }
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                                &shutdown_task, NULL);
 }
 
 
@@ -163,7 +168,8 @@
  * @return 0 ok, 1 on error
  */
 int
-main (int argc, char *const *argv)
+main (int argc,
+      char *const *argv)
 {
   int res;
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {




reply via email to

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