* @param peers Array of peer identities that participate in the tunnel.
* @param npeers Number of peers in peers.
*/
-typedef void (*GNUNET_MESH_MonitorCB) (void *cls,
+typedef void (*GNUNET_MESH_TunnelsCB) (void *cls,
const struct GNUNET_PeerIdentity *owner,
unsigned int tunnel_number,
const struct GNUNET_PeerIdentity *peers,
/**
- * Method called to retrieve information about each tunnel the mesh peer
- * is aware of.
+ * Method called to retrieve information about a specific tunnel the mesh peer
+ * is aware of, including all transit nodes.
*
* @param cls Closure.
- * @param initiator Peer that started the tunnel (owner).
- * @param tunnel_number Tunnel number.
- * @param peers Array of peers that form the tunnel, including transit nodes.
- * The identities come in pairs, representing a peer
- * and his predecessor in the tree. The root does not
- * appear in the array.
- * @param npeers Number of peers in peers (size is 2 x npeers!).
+ * @param peer Peer in the tunnel's tree.
+ * @param parent Parent of the current peer. All 0 when peer is root.
*/
-typedef void (*GNUNET_MESH_MonitorTunnelCB) (
- void *cls,
- const struct GNUNET_PeerIdentity *owner,
- unsigned int tunnel_number,
- const struct GNUNET_PeerIdentity *peers,
- unsigned int npeers);
+typedef void (*GNUNET_MESH_TunnelCB) (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_PeerIdentity *parent);
/**
* Request information about the running mesh peer.
* The callback will be called for every tunnel known to the service,
- * listing all peers that blong to the tunnel (active only).
+ * listing all active peers that blong to the tunnel.
*
* If called again on the same handle, it will overwrite the previous
* callback and cls. To retrieve the cls, monitor_cancel must be
* @param callback_cls Closure for @c callback.
*/
void
-GNUNET_MESH_monitor (struct GNUNET_MESH_Handle *h,
- GNUNET_MESH_MonitorCB callback,
- void *callback_cls);
+GNUNET_MESH_get_tunnels (struct GNUNET_MESH_Handle *h,
+ GNUNET_MESH_TunnelsCB callback,
+ void *callback_cls);
/**
* @param callback_cls Closure for @c callback.
*/
void
-GNUNET_MESH_monitor_tunnel (struct GNUNET_MESH_Handle *h,
- struct GNUNET_PeerIdentity *initiator,
- unsigned int tunnel_number,
- GNUNET_MESH_MonitorTunnelCB callback,
- void *callback_cls);
+GNUNET_MESH_show_tunnel (struct GNUNET_MESH_Handle *h,
+ struct GNUNET_PeerIdentity *initiator,
+ unsigned int tunnel_number,
+ GNUNET_MESH_TunnelCB callback,
+ void *callback_cls);
/**
* @return Closure given to GNUNET_MESH_monitor, if any.
*/
void *
-GNUNET_MESH_monitor_cancel (struct GNUNET_MESH_Handle *h);
+GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h);
/**
*/
static int monitor_connections;
+/**
+ * Option -t
+ */
+static char *tunnel_id;
/**
* Mesh handle.
*/
static struct GNUNET_MESH_Handle *mh;
+/**
+ * Shutdown task handle.
+ */
+GNUNET_SCHEDULER_TaskIdentifier sd;
/**
* Task run in monitor mode when the user presses CTRL-C to abort.
* @param npeers Number of peers in peers.
*/
static void
-monitor_callback (void *cls,
+tunnels_callback (void *cls,
const struct GNUNET_PeerIdentity *initiator,
unsigned int tunnel_number,
const struct GNUNET_PeerIdentity *peers,
/**
- * Call MESH's monitor API, start monitoring process
+ * Method called to retrieve information about each tunnel the mesh peer
+ * is aware of.
+ *
+ * @param cls Closure.
+ * @param peer Peer in the tunnel's tree.
+ * @param parent Parent of the current peer. All 0 when peer is root.
+ *
+ */
+static void
+tunnel_callback (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_PeerIdentity *parent)
+{
+}
+
+
+/**
+ * Call MESH's monitor API, get all tunnels known to peer.
*
* @param cls Closure (unused).
* @param tc TaskContext
*/
static void
-monitor (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
return;
}
- GNUNET_MESH_monitor (mh, &monitor_callback, NULL);
- if (GNUNET_YES == monitor_connections)
+ GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL);
+ if (GNUNET_YES != monitor_connections)
+ {
+ GNUNET_SCHEDULER_shutdown();
+ }
+}
+
+/**
+ * Call MESH's monitor API, get info of one tunnel.
+ *
+ * @param cls Closure (unused).
+ * @param tc TaskContext
+ */
+static void
+show_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_PeerIdentity pid;
+
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_hash_from_string (tunnel_id, &pid.hashPubKey))
{
- /* keep open */
+ GNUNET_SCHEDULER_shutdown();
+ return;
}
+ GNUNET_MESH_show_tunnel (mh, &pid, 0, tunnel_callback, NULL);
}
if (NULL == mh)
GNUNET_SCHEDULER_add_now (shutdown_task, NULL);
else
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- shutdown_task, NULL);
- GNUNET_SCHEDULER_add_now (&monitor, NULL);
+ sd = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ shutdown_task, NULL);
+
+ if (NULL != tunnel_id)
+ GNUNET_SCHEDULER_add_now (&show_tunnel, NULL);
+ else
+ GNUNET_SCHEDULER_add_now (&get_tunnels, NULL);
}
int res;
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'m', "monitor", NULL,
- gettext_noop ("provide inthe 'struct GNUNET_TRANSPORT_PeerIterateContextformation about all tunnels (continuously)"),
- 0, &GNUNET_GETOPT_set_one, &monitor_connections},
+ gettext_noop ("provide information about all tunnels (continuously) NOT IMPLEMENTED"), /* FIXME */
+ GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_connections},
+ {'t', "tunnel", "OWNER_ID:TUNNEL_ID",
+ gettext_noop ("provide information about a particular tunnel"),
+ GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
-
res = GNUNET_PROGRAM_run (argc, argv, "gnunet-mesh",
gettext_noop
("Print information about mesh tunnels and peers."),
/**
* Monitor callback
*/
- GNUNET_MESH_MonitorCB monitor_cb;
+ GNUNET_MESH_TunnelsCB tunnels_cb;
/**
* Monitor callback closure.
*/
- void *monitor_cls;
+ void *tunnels_cls;
/**
* Tunnel callback.
*/
- GNUNET_MESH_MonitorTunnelCB tunnel_cb;
+ GNUNET_MESH_TunnelCB tunnel_cb;
/**
* Tunnel callback closure.
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Monitor messasge received\n");
- if (NULL == h->monitor_cb)
+ if (NULL == h->tunnels_cb)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n");
return;
npeers);
return;
}
- h->monitor_cb (h->monitor_cls,
+ h->tunnels_cb (h->tunnels_cls,
&msg->owner,
ntohl (msg->tunnel_id),
(struct GNUNET_PeerIdentity *) &msg[1],
/**
* Request information about the running mesh peer.
* The callback will be called for every tunnel known to the service,
- * listing all peers that blong to the tunnel (active only).
+ * listing all active peers that blong to the tunnel.
*
* If called again on the same handle, it will overwrite the previous
* callback and cls. To retrieve the cls, monitor_cancel must be
* @param callback_cls Closure for @c callback.
*/
void
-GNUNET_MESH_monitor (struct GNUNET_MESH_Handle *h,
- GNUNET_MESH_MonitorCB callback,
- void *callback_cls)
+GNUNET_MESH_get_tunnels (struct GNUNET_MESH_Handle *h,
+ GNUNET_MESH_TunnelsCB callback,
+ void *callback_cls)
{
struct GNUNET_MessageHeader msg;
msg.size = htons (sizeof (msg));
msg.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_MONITOR);
send_packet (h, &msg, NULL);
- h->monitor_cb = callback;
- h->monitor_cls = callback_cls;
+ h->tunnels_cb = callback;
+ h->tunnels_cls = callback_cls;
return;
}
* @return Closure given to GNUNET_MESH_monitor, if any.
*/
void *
-GNUNET_MESH_monitor_cancel (struct GNUNET_MESH_Handle *h)
+GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h)
{
void *cls;
- cls = h->monitor_cls;
- h->monitor_cb = NULL;
- h->monitor_cls = NULL;
+ cls = h->tunnels_cls;
+ h->tunnels_cb = NULL;
+ h->tunnels_cls = NULL;
return cls;
}
* @param callback_cls Closure for @c callback.
*/
void
-GNUNET_MESH_monitor_tunnel (struct GNUNET_MESH_Handle *h,
- struct GNUNET_PeerIdentity *initiator,
- unsigned int tunnel_number,
- GNUNET_MESH_MonitorTunnelCB callback,
- void *callback_cls)
+GNUNET_MESH_show_tunnel (struct GNUNET_MESH_Handle *h,
+ struct GNUNET_PeerIdentity *initiator,
+ unsigned int tunnel_number,
+ GNUNET_MESH_TunnelCB callback,
+ void *callback_cls)
{
struct GNUNET_MESH_LocalMonitor msg;