aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-core.19
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/core/gnunet-core.c100
3 files changed, 60 insertions, 50 deletions
diff --git a/doc/man/gnunet-core.1 b/doc/man/gnunet-core.1
index 0971b423c..e2ada055a 100644
--- a/doc/man/gnunet-core.1
+++ b/doc/man/gnunet-core.1
@@ -1,6 +1,6 @@
1.TH gnunet\-core "1" "1 Apr 2012" "GNUnet" 1.TH gnunet\-core "1" "11 Apr 2014" "GNUnet"
2.SH NAME 2.SH NAME
3gnunet\-core \- measure and control the core subsystem 3gnunet\-core \- monitor CORE subsystem
4 4
5.SH SYNOPSIS 5.SH SYNOPSIS
6.B gnunet\-core 6.B gnunet\-core
@@ -8,7 +8,7 @@ gnunet\-core \- measure and control the core subsystem
8.SH DESCRIPTION 8.SH DESCRIPTION
9.PP 9.PP
10 10
11gnunet\-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). 11gnunet\-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.
12 12
13.TP 13.TP
14\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR 14\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR
@@ -20,6 +20,9 @@ print help page
20\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR 20\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
21Change the loglevel. Possible values for LOGLEVEL are ERROR, WARNING, INFO and DEBUG. 21Change the loglevel. Possible values for LOGLEVEL are ERROR, WARNING, INFO and DEBUG.
22.TP 22.TP
23\fB\-m\fR, \fB\-\-monitor\fR
24in monitor mode, gnunet\-core will continuously print the connection status, instead of giving just a snapshot
25.TP
23\fB\-v\fR, \fB\-\-version\fR 26\fB\-v\fR, \fB\-\-version\fR
24print the version number 27print the version number
25.TP 28.TP
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3e1535ea9..6eb492153 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -182,6 +182,7 @@ src/identity/identity_api.c
182src/identity/identity_api_lookup.c 182src/identity/identity_api_lookup.c
183src/mesh/gnunet-mesh.c 183src/mesh/gnunet-mesh.c
184src/mesh/gnunet-mesh-profiler.c 184src/mesh/gnunet-mesh-profiler.c
185src/mesh/gnunet-mesh-profiler.c
185src/mesh/gnunet-service-mesh.c 186src/mesh/gnunet-service-mesh.c
186src/mesh/gnunet-service-mesh_channel.c 187src/mesh/gnunet-service-mesh_channel.c
187src/mesh/gnunet-service-mesh_connection.c 188src/mesh/gnunet-service-mesh_connection.c
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 36dc5fc6f..25127da66 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file core/gnunet-core.c 22 * @file core/gnunet-core.c
23 * @brief Print information about other known _connected_ peers. 23 * @brief Print information about other peers known to CORE.
24 * @author Nathan Evans 24 * @author Nathan Evans
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
@@ -34,11 +34,6 @@
34static int monitor_connections; 34static int monitor_connections;
35 35
36/** 36/**
37 * Current number of connections in monitor mode
38 */
39// static unsigned int monitor_connections_counter;
40
41/**
42 * Handle to the CORE monitor. 37 * Handle to the CORE monitor.
43 */ 38 */
44static struct GNUNET_CORE_MonitorHandle *mh; 39static struct GNUNET_CORE_MonitorHandle *mh;
@@ -48,7 +43,7 @@ static struct GNUNET_CORE_MonitorHandle *mh;
48 * Task run in monitor mode when the user presses CTRL-C to abort. 43 * Task run in monitor mode when the user presses CTRL-C to abort.
49 * Stops monitoring activity. 44 * Stops monitoring activity.
50 * 45 *
51 * @param cls the 'struct GNUNET_TRANSPORT_PeerIterateContext *' 46 * @param cls NULL
52 * @param tc scheduler context 47 * @param tc scheduler context
53 */ 48 */
54static void 49static void
@@ -80,53 +75,54 @@ monitor_cb (void *cls,
80{ 75{
81 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 76 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
82 const char *now_str; 77 const char *now_str;
78 const char *state_str;
83 79
84 if ( (NULL == peer) && 80 if ( ( (NULL == peer) ||
81 (GNUNET_CORE_KX_ITERATION_FINISHED == state) ) &&
85 (GNUNET_NO == monitor_connections) ) 82 (GNUNET_NO == monitor_connections) )
86 { 83 {
87 GNUNET_SCHEDULER_shutdown (); 84 GNUNET_SCHEDULER_shutdown ();
88 return; 85 return;
89 } 86 }
90 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
91 FPRINTF (stdout,
92 _("%24s: %-17s %d %4s\n"),
93 now_str,
94 "FIXME",
95 state,
96 GNUNET_i2s (peer));
97}
98
99
100/**
101 * Function called with the result of the check if the CORE
102 * service is running.
103 *
104 * @param cls closure with our configuration
105 * @param result #GNUNET_YES if CORE is running
106 */
107static void
108testservice_task (void *cls,
109 int result)
110{
111 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
112 87
113 if (GNUNET_OK != result) 88 switch (state)
114 { 89 {
115 FPRINTF (stderr, _("Service `%s' is not running\n"), "core"); 90 case GNUNET_CORE_KX_STATE_DOWN:
91 /* should never happen, as we immediately send the key */
92 state_str = _("fresh connection");
93 break;
94 case GNUNET_CORE_KX_STATE_KEY_SENT:
95 state_str = _("key sent");
96 break;
97 case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
98 state_str = _("key received");
99 break;
100 case GNUNET_CORE_KX_STATE_UP:
101 state_str = _("connection established");
102 break;
103 case GNUNET_CORE_KX_STATE_REKEY_SENT:
104 state_str = _("rekeying");
105 break;
106 case GNUNET_CORE_KX_PEER_DISCONNECT:
107 state_str = _("disconnected");
108 break;
109 case GNUNET_CORE_KX_ITERATION_FINISHED:
116 return; 110 return;
117 } 111 case GNUNET_CORE_KX_CORE_DISCONNECT:
118 112 FPRINTF (stderr,
119 mh = GNUNET_CORE_monitor_start (cfg, 113 "%s\n",
120 &monitor_cb, 114 _("Connection to CORE service lost (reconnecting)"));
121 NULL);
122 if (NULL == mh)
123 {
124 GNUNET_SCHEDULER_add_now (shutdown_task, NULL);
125 fprintf (stderr, ("Failed to connect to CORE service!\n"));
126 return; 115 return;
116 default:
117 state_str = _("unknown state");
118 break;
127 } 119 }
128 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 120 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
129 &shutdown_task, NULL); 121 FPRINTF (stdout,
122 _("%24s: %-17s %4s\n"),
123 now_str,
124 state_str,
125 GNUNET_i2s (peer));
130} 126}
131 127
132 128
@@ -149,9 +145,18 @@ run (void *cls, char *const *args, const char *cfgfile,
149 args[0]); 145 args[0]);
150 return; 146 return;
151 } 147 }
152 GNUNET_CLIENT_service_test ("core", cfg, 148 mh = GNUNET_CORE_monitor_start (cfg,
153 GNUNET_TIME_UNIT_SECONDS, 149 &monitor_cb,
154 &testservice_task, (void *) cfg); 150 NULL);
151 if (NULL == mh)
152 {
153 FPRINTF (stderr,
154 "%s",
155 _("Failed to connect to CORE service!\n"));
156 return;
157 }
158 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
159 &shutdown_task, NULL);
155} 160}
156 161
157 162
@@ -163,7 +168,8 @@ run (void *cls, char *const *args, const char *cfgfile,
163 * @return 0 ok, 1 on error 168 * @return 0 ok, 1 on error
164 */ 169 */
165int 170int
166main (int argc, char *const *argv) 171main (int argc,
172 char *const *argv)
167{ 173{
168 int res; 174 int res;
169 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 175 static const struct GNUNET_GETOPT_CommandLineOption options[] = {