gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19707 - in gnunet: doc/man src/transport


From: gnunet
Subject: [GNUnet-SVN] r19707 - in gnunet: doc/man src/transport
Date: Mon, 6 Feb 2012 10:34:52 +0100

Author: grothoff
Date: 2012-02-06 10:34:52 +0100 (Mon, 06 Feb 2012)
New Revision: 19707

Modified:
   gnunet/doc/man/gnunet-transport.1
   gnunet/src/transport/gnunet-transport.c
Log:
adding -m option to gnunet-transport to enable monitor mode (see #1972)

Modified: gnunet/doc/man/gnunet-transport.1
===================================================================
--- gnunet/doc/man/gnunet-transport.1   2012-02-06 09:17:11 UTC (rev 19706)
+++ gnunet/doc/man/gnunet-transport.1   2012-02-06 09:34:52 UTC (rev 19707)
@@ -26,6 +26,9 @@
 \fB\-i\fR, \fB\-\-information\fR
 print information about our current connections (once)
 .TP
+\fB\-m\fR, \fB\-\-monitor\fR
+print information about our current connections (continuously)
+.TP
 \fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
 Change the loglevel.  Possible values for LOGLEVEL are ERROR, WARNING, INFO 
and DEBUG.
 .TP

Modified: gnunet/src/transport/gnunet-transport.c
===================================================================
--- gnunet/src/transport/gnunet-transport.c     2012-02-06 09:17:11 UTC (rev 
19706)
+++ gnunet/src/transport/gnunet-transport.c     2012-02-06 09:34:52 UTC (rev 
19707)
@@ -76,6 +76,11 @@
 static int test_configuration;
 
 /**
+ * Option -m.
+ */
+static int monitor_connections;
+
+/**
  * Option -n.
  */
 static int numeric;
@@ -483,6 +488,24 @@
 
 
 /**
+ * Task run in monitor mode when the user presses CTRL-C to abort.
+ * Stops monitoring activity.
+ * 
+ * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *'
+ * @param tc scheduler context
+ */
+static void
+shutdown_task (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_TRANSPORT_PeerIterateContext *pic = cls;
+
+  GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);  
+}
+
+
+
+/**
  * Main function that will be run by the scheduler.
  *
  * @param cls closure
@@ -538,6 +561,17 @@
                                                 GNUNET_TIME_UNIT_MINUTES,
                                                 &process_address, (void *) 
cfg);
   }
+  if (monitor_connections)
+  {
+    struct GNUNET_TRANSPORT_PeerIterateContext *pic;
+
+    pic = GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_NO,
+                                                     
GNUNET_TIME_UNIT_FOREVER_REL,
+                                                     &process_address, (void 
*) cfg);
+    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                                 &shutdown_task,
+                                 pic);
+  }
 }
 
 
@@ -554,6 +588,12 @@
     {'i', "information", NULL,
      gettext_noop ("provide information about all current connections (once)"),
      0, &GNUNET_GETOPT_set_one, &iterate_connections},
+    {'m', "monitor", NULL,
+     gettext_noop ("provide information about all current connections 
(continuously)"),
+     0, &GNUNET_GETOPT_set_one, &monitor_connections},
+    {'n', "numeric", NULL,
+     gettext_noop ("do not resolve hostnames"),
+     0, &GNUNET_GETOPT_set_one, &numeric},
     {'s', "send", NULL,
      gettext_noop
      ("send data for benchmarking to the other peer (until CTRL-C)"),
@@ -561,9 +601,6 @@
     {'t', "test", NULL,
      gettext_noop ("test transport configuration (involves external server)"),
      0, &GNUNET_GETOPT_set_one, &test_configuration},
-    {'n', "numeric", NULL,
-     gettext_noop ("do not resolve hostnames"),
-     0, &GNUNET_GETOPT_set_one, &numeric},
     GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
     GNUNET_GETOPT_OPTION_END
   };




reply via email to

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