aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-cadet.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-06-18 00:22:35 +0000
committerBart Polot <bart@net.in.tum.de>2014-06-18 00:22:35 +0000
commite4d12b9b2c3584dba64e7b3ae2d2b466d09b6122 (patch)
tree6ce2dd59d449e26937745d3e6a901eb0a5fb6da0 /src/cadet/gnunet-cadet.c
parentd86a270b3b0691b651ee6d2b5d5a18b4bd27bbf8 (diff)
downloadgnunet-e4d12b9b2c3584dba64e7b3ae2d2b466d09b6122.tar.gz
gnunet-e4d12b9b2c3584dba64e7b3ae2d2b466d09b6122.zip
Add a debug "dump to stderr" feature to cadet
Diffstat (limited to 'src/cadet/gnunet-cadet.c')
-rw-r--r--src/cadet/gnunet-cadet.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index 2a43f570d..d6ae66331 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -32,7 +32,7 @@
32/** 32/**
33 * Option -m. 33 * Option -m.
34 */ 34 */
35static int monitor_connections; 35static int monitor_mode;
36 36
37/** 37/**
38 * Option -P. 38 * Option -P.
@@ -75,6 +75,11 @@ static uint32_t listen_port;
75int echo; 75int echo;
76 76
77/** 77/**
78 * Request a debug dump
79 */
80int dump;
81
82/**
78 * Time of last echo request. 83 * Time of last echo request.
79 */ 84 */
80struct GNUNET_TIME_Absolute echo_time; 85struct GNUNET_TIME_Absolute echo_time;
@@ -333,6 +338,20 @@ send_echo (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
333} 338}
334 339
335 340
341/**
342 * Call CADET's monitor API, request debug dump on the service.
343 *
344 * @param cls Closure (unused).
345 * @param tc TaskContext
346 */
347static void
348request_dump (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
349{
350 GNUNET_CADET_request_dump (mh);
351 GNUNET_SCHEDULER_cancel (sd);
352 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &shutdown_task, NULL);
353}
354
336 355
337/** 356/**
338 * Call CADET's monitor API, get info of one connection. 357 * Call CADET's monitor API, get info of one connection.
@@ -458,7 +477,7 @@ peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
458{ 477{
459 if (NULL == peer) 478 if (NULL == peer)
460 { 479 {
461 if (GNUNET_YES != monitor_connections) 480 if (GNUNET_YES != monitor_mode)
462 { 481 {
463 GNUNET_SCHEDULER_shutdown(); 482 GNUNET_SCHEDULER_shutdown();
464 } 483 }
@@ -512,7 +531,7 @@ tunnels_callback (void *cls,
512{ 531{
513 if (NULL == peer) 532 if (NULL == peer)
514 { 533 {
515 if (GNUNET_YES != monitor_connections) 534 if (GNUNET_YES != monitor_mode)
516 { 535 {
517 GNUNET_SCHEDULER_shutdown(); 536 GNUNET_SCHEDULER_shutdown();
518 } 537 }
@@ -560,7 +579,7 @@ tunnel_callback (void *cls,
560 FPRINTF (stdout, "- enc state: %u\n", estate); 579 FPRINTF (stdout, "- enc state: %u\n", estate);
561 FPRINTF (stdout, "- con state: %u\n", cstate); 580 FPRINTF (stdout, "- con state: %u\n", cstate);
562 } 581 }
563 if (GNUNET_YES != monitor_connections) 582 if (GNUNET_YES != monitor_mode)
564 { 583 {
565 GNUNET_SCHEDULER_shutdown(); 584 GNUNET_SCHEDULER_shutdown();
566 } 585 }
@@ -706,7 +725,7 @@ run (void *cls, char *const *args, const char *cfgfile,
706 target_id = args[0]; 725 target_id = args[0];
707 target_port = args[0] && args[1] ? atoi(args[1]) : 0; 726 target_port = args[0] && args[1] ? atoi(args[1]) : 0;
708 if ( (0 != (request_peers | request_tunnels) 727 if ( (0 != (request_peers | request_tunnels)
709 || 0 != monitor_connections 728 || 0 != monitor_mode
710 || NULL != tunnel_id 729 || NULL != tunnel_id
711 || NULL != conn_id 730 || NULL != conn_id
712 || NULL != channel_id) 731 || NULL != channel_id)
@@ -718,7 +737,13 @@ run (void *cls, char *const *args, const char *cfgfile,
718 return; 737 return;
719 } 738 }
720 739
721 if (NULL != target_id) 740 if (GNUNET_YES == dump)
741 {
742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
743 "requesting debug dump\n");
744 GNUNET_SCHEDULER_add_now (&request_dump, NULL);
745 }
746 else if (NULL != target_id)
722 { 747 {
723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
724 "Creating channel to %s\n", 749 "Creating channel to %s\n",
@@ -809,6 +834,9 @@ main (int argc, char *const *argv)
809 {'e', "echo", NULL, 834 {'e', "echo", NULL,
810 gettext_noop ("activate echo mode"), 835 gettext_noop ("activate echo mode"),
811 GNUNET_NO, &GNUNET_GETOPT_set_one, &echo}, 836 GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
837 {'d', "dump", NULL,
838 gettext_noop ("dump debug information to STDERR"),
839 GNUNET_NO, &GNUNET_GETOPT_set_one, &dump},
812// {'m', "monitor", NULL, 840// {'m', "monitor", NULL,
813// gettext_noop ("provide information about all events (continuously)"), 841// gettext_noop ("provide information about all events (continuously)"),
814// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode}, 842// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode},
@@ -831,7 +859,7 @@ main (int argc, char *const *argv)
831 GNUNET_GETOPT_OPTION_END 859 GNUNET_GETOPT_OPTION_END
832 }; 860 };
833 861
834 monitor_connections = GNUNET_NO; 862 monitor_mode = GNUNET_NO;
835 863
836 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 864 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
837 return 2; 865 return 2;