}
+/**
+ * Request a debug dump on the service's STDERR.
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h cadet handle
+ */
+void
+GNUNET_CADET_request_dump (struct GNUNET_CADET_Handle *h)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "requesting dump\n");
+ send_info_request (h, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP);
+}
+
+
/**
* Request information about peers known to the running cadet service.
* The callback will be called for every peer known to the service.
break;
/**
- * 640kb should be enough for everybody
+ * Debug request.
*/
- case 299:
- t = "RESERVE_END";
+ case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP:
+ t = "INFO_DUMP";
break;
default:
/**
* Option -m.
*/
-static int monitor_connections;
+static int monitor_mode;
/**
* Option -P.
*/
int echo;
+/**
+ * Request a debug dump
+ */
+int dump;
+
/**
* Time of last echo request.
*/
}
+/**
+ * Call CADET's monitor API, request debug dump on the service.
+ *
+ * @param cls Closure (unused).
+ * @param tc TaskContext
+ */
+static void
+request_dump (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_CADET_request_dump (mh);
+ GNUNET_SCHEDULER_cancel (sd);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &shutdown_task, NULL);
+}
+
/**
* Call CADET's monitor API, get info of one connection.
{
if (NULL == peer)
{
- if (GNUNET_YES != monitor_connections)
+ if (GNUNET_YES != monitor_mode)
{
GNUNET_SCHEDULER_shutdown();
}
{
if (NULL == peer)
{
- if (GNUNET_YES != monitor_connections)
+ if (GNUNET_YES != monitor_mode)
{
GNUNET_SCHEDULER_shutdown();
}
FPRINTF (stdout, "- enc state: %u\n", estate);
FPRINTF (stdout, "- con state: %u\n", cstate);
}
- if (GNUNET_YES != monitor_connections)
+ if (GNUNET_YES != monitor_mode)
{
GNUNET_SCHEDULER_shutdown();
}
target_id = args[0];
target_port = args[0] && args[1] ? atoi(args[1]) : 0;
if ( (0 != (request_peers | request_tunnels)
- || 0 != monitor_connections
+ || 0 != monitor_mode
|| NULL != tunnel_id
|| NULL != conn_id
|| NULL != channel_id)
return;
}
- if (NULL != target_id)
+ if (GNUNET_YES == dump)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "requesting debug dump\n");
+ GNUNET_SCHEDULER_add_now (&request_dump, NULL);
+ }
+ else if (NULL != target_id)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating channel to %s\n",
{'e', "echo", NULL,
gettext_noop ("activate echo mode"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
+ {'d', "dump", NULL,
+ gettext_noop ("dump debug information to STDERR"),
+ GNUNET_NO, &GNUNET_GETOPT_set_one, &dump},
// {'m', "monitor", NULL,
// gettext_noop ("provide information about all events (continuously)"),
// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode},
GNUNET_GETOPT_OPTION_END
};
- monitor_connections = GNUNET_NO;
+ monitor_mode = GNUNET_NO;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
}
-
/**
* Iterator over all peers to send a monitoring client info about each peer.
*
}
+/**
+ * Iterator over all peers to dump info for each peer.
+ *
+ * @param cls Closure (unused).
+ * @param peer Peer ID (tunnel remote peer).
+ * @param value Peer info.
+ *
+ * @return #GNUNET_YES, to keep iterating.
+ */
+static int
+show_peer_iterator (void *cls,
+ const struct GNUNET_PeerIdentity * peer,
+ void *value)
+{
+ struct CadetPeer *p = value;
+ struct CadetTunnel *t;
+
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Peer %s\n", GCP_2s (p));
+ LOG (GNUNET_ERROR_TYPE_ERROR, " %u paths\n", GCP_count_paths (p));
+
+ t = GCP_get_tunnel (p);
+ if (NULL != t)
+ GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR, "\n");
+
+ return GNUNET_YES;
+}
+
+
/**
* Handler for client's INFO PEERS request.
*
}
+/**
+ * Handler for client's INFO_DUMP request.
+ *
+ * @param cls Closure (unused).
+ * @param client Identification of the client.
+ * @param message The actual message.
+ */
+void
+handle_info_dump (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct CadetClient *c;
+
+ /* Sanity check for client registration */
+ if (NULL == (c = GML_client_get (client)))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Received dump info request from client %u\n",
+ c->id);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "*************************** DUMP START ***************************\n");
+
+ GCP_iterate_all (&show_peer_iterator, NULL);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "**************************** DUMP END ****************************\n");
+
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
/**
* Functions to handle messages from clients
*/
sizeof (struct GNUNET_MessageHeader)},
{&handle_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL,
sizeof (struct GNUNET_CADET_LocalInfo)},
+ {&handle_info_dump, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP,
+ sizeof (struct GNUNET_MessageHeader)},
{NULL, NULL, 0, 0}
};
GNUNET_CADET_ChannelCB callback,
void *callback_cls);
+/**
+ * Request a debug dump on the service's STDERR.
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h cadet handle
+ */
+void
+GNUNET_CADET_request_dump (struct GNUNET_CADET_Handle *h);
/**
* Request information about peers known to the running cadet service.
#define GNUNET_MESSAGE_TYPE_CADET_CLI 298
/**
- * 640kb should be enough for everybody
+ * Debug request.
*/
-#define GNUNET_MESSAGE_TYPE_CADET_RESERVE_END 299
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP 299
#define GNUNET_MESSAGE_TYPE_SOCIAL_JOIN_DECISION 848
/*******************************************************************************
- * X-VINE DHT messages
+ * X-VINE DHT messages
******************************************************************************/
/**
#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_REJECTION 886
/**
- * Trail Tear down Message.
+ * Trail Tear down Message.
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN 887
/**
- * Routing table add message.
+ * Routing table add message.
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL 888
/**
- * Trail compression message.
+ * Trail compression message.
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION 889