aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-transport.13
-rw-r--r--src/transport/gnunet-transport.c43
2 files changed, 43 insertions, 3 deletions
diff --git a/doc/man/gnunet-transport.1 b/doc/man/gnunet-transport.1
index bb7dc8085..cc1a022bd 100644
--- a/doc/man/gnunet-transport.1
+++ b/doc/man/gnunet-transport.1
@@ -26,6 +26,9 @@ print help page
26\fB\-i\fR, \fB\-\-information\fR 26\fB\-i\fR, \fB\-\-information\fR
27print information about our current connections (once) 27print information about our current connections (once)
28.TP 28.TP
29\fB\-m\fR, \fB\-\-monitor\fR
30print information about our current connections (continuously)
31.TP
29\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR 32\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
30Change the loglevel. Possible values for LOGLEVEL are ERROR, WARNING, INFO and DEBUG. 33Change the loglevel. Possible values for LOGLEVEL are ERROR, WARNING, INFO and DEBUG.
31.TP 34.TP
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index c78518813..4b0c08f54 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -76,6 +76,11 @@ static int iterate_connections;
76static int test_configuration; 76static int test_configuration;
77 77
78/** 78/**
79 * Option -m.
80 */
81static int monitor_connections;
82
83/**
79 * Option -n. 84 * Option -n.
80 */ 85 */
81static int numeric; 86static int numeric;
@@ -483,6 +488,24 @@ process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
483 488
484 489
485/** 490/**
491 * Task run in monitor mode when the user presses CTRL-C to abort.
492 * Stops monitoring activity.
493 *
494 * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *'
495 * @param tc scheduler context
496 */
497static void
498shutdown_task (void *cls,
499 const struct GNUNET_SCHEDULER_TaskContext *tc)
500{
501 struct GNUNET_TRANSPORT_PeerIterateContext *pic = cls;
502
503 GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
504}
505
506
507
508/**
486 * Main function that will be run by the scheduler. 509 * Main function that will be run by the scheduler.
487 * 510 *
488 * @param cls closure 511 * @param cls closure
@@ -538,6 +561,17 @@ run (void *cls, char *const *args, const char *cfgfile,
538 GNUNET_TIME_UNIT_MINUTES, 561 GNUNET_TIME_UNIT_MINUTES,
539 &process_address, (void *) cfg); 562 &process_address, (void *) cfg);
540 } 563 }
564 if (monitor_connections)
565 {
566 struct GNUNET_TRANSPORT_PeerIterateContext *pic;
567
568 pic = GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_NO,
569 GNUNET_TIME_UNIT_FOREVER_REL,
570 &process_address, (void *) cfg);
571 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
572 &shutdown_task,
573 pic);
574 }
541} 575}
542 576
543 577
@@ -554,6 +588,12 @@ main (int argc, char *const *argv)
554 {'i', "information", NULL, 588 {'i', "information", NULL,
555 gettext_noop ("provide information about all current connections (once)"), 589 gettext_noop ("provide information about all current connections (once)"),
556 0, &GNUNET_GETOPT_set_one, &iterate_connections}, 590 0, &GNUNET_GETOPT_set_one, &iterate_connections},
591 {'m', "monitor", NULL,
592 gettext_noop ("provide information about all current connections (continuously)"),
593 0, &GNUNET_GETOPT_set_one, &monitor_connections},
594 {'n', "numeric", NULL,
595 gettext_noop ("do not resolve hostnames"),
596 0, &GNUNET_GETOPT_set_one, &numeric},
557 {'s', "send", NULL, 597 {'s', "send", NULL,
558 gettext_noop 598 gettext_noop
559 ("send data for benchmarking to the other peer (until CTRL-C)"), 599 ("send data for benchmarking to the other peer (until CTRL-C)"),
@@ -561,9 +601,6 @@ main (int argc, char *const *argv)
561 {'t', "test", NULL, 601 {'t', "test", NULL,
562 gettext_noop ("test transport configuration (involves external server)"), 602 gettext_noop ("test transport configuration (involves external server)"),
563 0, &GNUNET_GETOPT_set_one, &test_configuration}, 603 0, &GNUNET_GETOPT_set_one, &test_configuration},
564 {'n', "numeric", NULL,
565 gettext_noop ("do not resolve hostnames"),
566 0, &GNUNET_GETOPT_set_one, &numeric},
567 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity), 604 GNUNET_GETOPT_OPTION_VERBOSE (&verbosity),
568 GNUNET_GETOPT_OPTION_END 605 GNUNET_GETOPT_OPTION_END
569 }; 606 };