[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31887 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31887 - gnunet/src/mesh |
Date: |
Mon, 13 Jan 2014 20:33:49 +0100 |
Author: bartpolot
Date: 2014-01-13 20:33:49 +0100 (Mon, 13 Jan 2014)
New Revision: 31887
Modified:
gnunet/src/mesh/gnunet-mesh.c
gnunet/src/mesh/gnunet-service-mesh_local.c
gnunet/src/mesh/gnunet-service-mesh_peer.c
gnunet/src/mesh/gnunet-service-mesh_tunnel.c
gnunet/src/mesh/gnunet-service-mesh_tunnel.h
gnunet/src/mesh/mesh.h
gnunet/src/mesh/mesh_api.c
Log:
- various CLI fixes
Modified: gnunet/src/mesh/gnunet-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-mesh.c 2014-01-13 16:59:57 UTC (rev 31886)
+++ gnunet/src/mesh/gnunet-mesh.c 2014-01-13 19:33:49 UTC (rev 31887)
@@ -659,21 +659,21 @@
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},
Modified: gnunet/src/mesh/gnunet-service-mesh_local.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.c 2014-01-13 16:59:57 UTC (rev
31886)
+++ gnunet/src/mesh/gnunet-service-mesh_local.c 2014-01-13 19:33:49 UTC (rev
31887)
@@ -651,8 +651,19 @@
}
+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.
@@ -663,9 +674,12 @@
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)))
@@ -677,18 +691,23 @@
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 = *msg;
+ 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);
+
GNUNET_SERVER_notification_context_unicast (nc, client,
&warn.header,
GNUNET_NO);
@@ -697,16 +716,27 @@
}
/* 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);
}
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c 2014-01-13 16:59:57 UTC (rev
31886)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c 2014-01-13 19:33:49 UTC (rev
31887)
@@ -1787,7 +1787,6 @@
struct MeshTunnel3 *
GMP_get_tunnel (const struct MeshPeer *peer)
{
- GNUNET_assert (NULL != peer->tunnel);
return peer->tunnel;
}
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2014-01-13 16:59:57 UTC
(rev 31886)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2014-01-13 19:33:49 UTC
(rev 31887)
@@ -2660,3 +2660,21 @@
{
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);
+}
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.h 2014-01-13 16:59:57 UTC
(rev 31886)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.h 2014-01-13 19:33:49 UTC
(rev 31887)
@@ -123,7 +123,10 @@
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
***********************************/
/******************************************************************************/
@@ -479,6 +482,12 @@
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
Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h 2014-01-13 16:59:57 UTC (rev 31886)
+++ gnunet/src/mesh/mesh.h 2014-01-13 19:33:49 UTC (rev 31887)
@@ -181,12 +181,12 @@
/**
* 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;
};
/**
Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c 2014-01-13 16:59:57 UTC (rev 31886)
+++ gnunet/src/mesh/mesh_api.c 2014-01-13 19:33:49 UTC (rev 31887)
@@ -1804,7 +1804,7 @@
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;
@@ -1834,7 +1834,7 @@
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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31887 - gnunet/src/mesh,
gnunet <=