int res;
const char helpstr[] = "Create channels and retreive info about meshs status.";
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'a', "channel", "TUNNEL_ID:CHANNEL_ID",
- gettext_noop ("provide information about a particular channel"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &channel_id},
- {'b', "connection", "TUNNEL_ID:CONNECTION_ID",
- gettext_noop ("provide information about a particular connection"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
+// {'a', "channel", "TUNNEL_ID:CHANNEL_ID",
+// gettext_noop ("provide information about a particular channel"),
+// GNUNET_YES, &GNUNET_GETOPT_set_string, &channel_id},
+// {'b', "connection", "TUNNEL_ID:CONNECTION_ID",
+// gettext_noop ("provide information about a particular connection"),
+// GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
{'e', "echo", NULL,
gettext_noop ("activate echo mode"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
{'i', "info", NULL,
gettext_noop ("provide information about all tunnels"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &get_info},
- {'m', "monitor", NULL,
- gettext_noop ("provide information about all tunnels (continuously) NOT IMPLEMENTED"), /* FIXME */
- GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_connections},
+// {'m', "monitor", NULL,
+// gettext_noop ("provide information about all tunnels (continuously) NOT IMPLEMENTED"), /* FIXME */
+// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_connections},
{'p', "port", NULL,
gettext_noop ("port to listen to (default; 0)"),
GNUNET_YES, &GNUNET_GETOPT_set_uint, &listen_port},
}
+static void
+iter_connection (void *cls, struct MeshConnection *c)
+{
+}
+
+static void
+iter_channel (void *cls, struct MeshChannel *ch)
+{
+}
+
+
/**
- * Handler for client's MONITOR_TUNNEL request.
+ * Handler for client's SHOW_TUNNEL request.
*
* @param cls Closure (unused).
* @param client Identification of the client.
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_MESH_LocalInfo *msg;
- struct GNUNET_MESH_LocalInfo *resp;
+ struct GNUNET_MESH_LocalInfoTunnel *resp;
struct MeshClient *c;
- struct MeshChannel *ch;
+ struct MeshTunnel3 *t;
+ unsigned int ch_n;
+ unsigned int c_n;
+ size_t size;
/* Sanity check for client registration */
if (NULL == (c = GML_client_get (client)))
msg = (struct GNUNET_MESH_LocalInfo *) message;
LOG (GNUNET_ERROR_TYPE_INFO,
- "Received tunnel info request from client %u for tunnel %s[%X]\n",
- c->id,
- &msg->owner,
- ntohl (msg->channel_id));
-// ch = channel_get (&msg->owner, ntohl (msg->channel_id));
- ch = NULL; // FIXME
- if (NULL == ch)
+ "Received tunnel info request from client %u for tunnel %s\n",
+ c->id, GNUNET_i2s_full(&msg->peer));
+
+ t = GMP_get_tunnel (GMP_get (&msg->peer));
+ if (NULL == t)
{
/* We don't know the tunnel */
- struct GNUNET_MESH_LocalInfo warn;
+ struct GNUNET_MESH_LocalInfoTunnel warn;
+
+ warn.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
+ warn.header.size = htons (sizeof (warn));
+ warn.destination = msg->peer;
+ warn.channels = htonl (0);
+ warn.connections = htonl (0);
+ warn.cstate = htons (0);
+ warn.estate = htons (0);
- warn = *msg;
GNUNET_SERVER_notification_context_unicast (nc, client,
&warn.header,
GNUNET_NO);
}
/* Initialize context */
- resp = GNUNET_new (struct GNUNET_MESH_LocalInfo);
- *resp = *msg;
- resp->header.size = htons (sizeof (struct GNUNET_MESH_LocalInfo));
+ ch_n = GMT_count_channels (t);
+ c_n = GMT_count_connections (t);
+
+ size = sizeof (struct GNUNET_MESH_LocalInfo);
+ size += c_n * sizeof (struct GNUNET_HashCode);
+ size += ch_n * sizeof (uint32_t);
+
+ resp = GNUNET_malloc (size);
+ resp->header.size = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
+ resp->header.size = htons (size);
+ GMT_iterate_connections (t, &iter_connection, resp);
+ GMT_iterate_channels (t, &iter_channel, resp);
+ resp->cstate = htons (GMT_get_cstate (t));
+ resp->estate = htons (GMT_get_estate (t));
GNUNET_SERVER_notification_context_unicast (nc, c->handle,
&resp->header, GNUNET_NO);
GNUNET_free (resp);
LOG (GNUNET_ERROR_TYPE_INFO,
- "Monitor tunnel request from client %u completed\n",
- c->id);
+ "Show tunnel request from client %u completed\n",
+ c->id);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
struct MeshTunnel3 *
GMP_get_tunnel (const struct MeshPeer *peer)
{
- GNUNET_assert (NULL != peer->tunnel);
return peer->tunnel;
}
{
return GNUNET_CONTAINER_multipeermap_size (tunnels);
}
+
+void
+GMT_iterate_connections (struct MeshTunnel3 *t, GMT_conn_iter iter, void *cls)
+{
+ struct MeshTConnection *ct;
+
+ for (ct = t->connection_head; NULL != ct; ct = ct->next)
+ iter (cls, ct->c);
+}
+
+void
+GMT_iterate_channels (struct MeshTunnel3 *t, GMT_chan_iter iter, void *cls)
+{
+ struct MeshTChannel *cht;
+
+ for (cht = t->channel_head; NULL != cht; cht = cht->next)
+ iter (cls, cht->ch);
+}
struct MeshTunnel3Queue *q,
uint16_t type, size_t size);
+typedef void (*GMT_conn_iter) (void *cls, struct MeshConnection *c);
+typedef void (*GMT_chan_iter) (void *cls, struct MeshChannel *ch);
+
/******************************************************************************/
/******************************** API ***********************************/
unsigned int
GMT_count_all (void);
+void
+GMT_iterate_connections (struct MeshTunnel3 *t, GMT_conn_iter iter, void *cls);
+
+void
+GMT_iterate_channels (struct MeshTunnel3 *t, GMT_chan_iter iter, void *cls);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
/**
* ID of the owner of the channel (can be local peer).
*/
- struct GNUNET_PeerIdentity owner;
+// struct GNUNET_PeerIdentity owner;
/**
* ID of the destination of the channel (can be local peer).
*/
- struct GNUNET_PeerIdentity destination;
+ struct GNUNET_PeerIdentity peer;
};
/**
memset (&msg, 0, sizeof (msg));
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
- msg.destination = *id;
+ msg.peer = *id;
send_packet (h, &msg.header, NULL);
h->tunnel_cb = callback;
h->tunnel_cls = callback_cls;
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL);
- msg.owner = *initiator;
+ msg.peer = *initiator;
msg.channel_id = htonl (channel_number);
// msg.reserved = 0;
send_packet (h, &msg.header, NULL);