[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31795 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31795 - gnunet/src/mesh |
Date: |
Mon, 6 Jan 2014 05:38:54 +0100 |
Author: bartpolot
Date: 2014-01-06 05:38:54 +0100 (Mon, 06 Jan 2014)
New Revision: 31795
Modified:
gnunet/src/mesh/gnunet-mesh.c
gnunet/src/mesh/gnunet-service-mesh_local.c
gnunet/src/mesh/mesh_api.c
Log:
- add -i function back to CLI
Modified: gnunet/src/mesh/gnunet-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-mesh.c 2014-01-06 04:36:42 UTC (rev 31794)
+++ gnunet/src/mesh/gnunet-mesh.c 2014-01-06 04:38:54 UTC (rev 31795)
@@ -425,40 +425,52 @@
/**
- * Method called to retrieve information about each tunnel the mesh peer
- * is aware of.
+ * Method called to retrieve information about all tunnels in MESH.
*
* @param cls Closure.
- * @param tunnel_number Tunnel number.
- * @param origin that started the tunnel (owner).
- * @param target other endpoint of the tunnel
+ * @param peer Destination peer.
+ * @param channels Number of channels.
+ * @param connections Number of connections.
+ * @param estate Encryption state.
+ * @param cstate Connectivity state.
*/
-void /* FIXME static */
+void
tunnels_callback (void *cls,
- uint32_t tunnel_number,
- const struct GNUNET_PeerIdentity *origin,
- const struct GNUNET_PeerIdentity *target)
+ const struct GNUNET_PeerIdentity *peer,
+ unsigned int channels,
+ unsigned int connections,
+ unsigned int estate,
+ unsigned int cstate)
{
- FPRINTF (stdout, "Tunnel %s [%u]\n",
- GNUNET_i2s_full (origin), tunnel_number);
- FPRINTF (stdout, "\n");
+ FPRINTF (stdout, "%s [%u, %u] CH: %u, C: %u\n",
+ GNUNET_i2s_full (peer), estate, cstate, channels, connections);
}
/**
- * 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
+ * has established, o`r is trying to establish.
*
* @param cls Closure.
- * @param peer Peer in the tunnel's tree.
- * @param parent Parent of the current peer. All 0 when peer is root.
- *
+ * @param peer Peer towards whom the tunnel is directed.
+ * @param channels Number of channels.
+ * @param connections Number of connections.
+ * @param estate Encryption status.
+ * @param cstate Connectivity status.
*/
-void /* FIXME static */
+void
tunnel_callback (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_PeerIdentity *parent)
+ unsigned int channels,
+ unsigned int connections,
+ unsigned int estate,
+ unsigned int cstate)
{
+ FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
+ FPRINTF (stdout, "- %u channels\n", channels);
+ FPRINTF (stdout, "- %u connections\n", connections);
+ FPRINTF (stdout, "- enc state: %u\n", estate);
+ FPRINTF (stdout, "- con state: %u\n", cstate);
}
@@ -475,7 +487,7 @@
{
return;
}
-// GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL);
+ GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL);
if (GNUNET_YES != monitor_connections)
{
GNUNET_SCHEDULER_shutdown();
@@ -505,7 +517,7 @@
GNUNET_SCHEDULER_shutdown();
return;
}
-// GNUNET_MESH_show_tunnel (mh, &pid, 0, tunnel_callback, NULL);
+ GNUNET_MESH_get_tunnel (mh, &pid, tunnel_callback, NULL);
}
@@ -662,6 +674,7 @@
{'t', "tunnel", "TUNNEL_ID",
gettext_noop ("provide information about a particular tunnel"),
GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
+
GNUNET_GETOPT_OPTION_END
};
Modified: gnunet/src/mesh/gnunet-service-mesh_local.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.c 2014-01-06 04:36:42 UTC (rev
31794)
+++ gnunet/src/mesh/gnunet-service-mesh_local.c 2014-01-06 04:38:54 UTC (rev
31795)
@@ -593,20 +593,22 @@
void *value)
{
struct GNUNET_SERVER_Client *client = cls;
- struct MeshChannel *ch = value;
- struct GNUNET_MESH_LocalInfo *msg;
+ struct MeshTunnel3 *t = value;
+ struct GNUNET_MESH_LocalInfoTunnel msg;
- msg = GNUNET_new (struct GNUNET_MESH_LocalInfo);
- msg->channel_id = htonl (GMCH_get_id (ch));
- msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalInfo));
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
+ msg.header.size = htons (sizeof (msg));
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
+ msg.destination = *peer;
+ msg.channels = htons (42);
+ msg.connections = htons (42);
+ msg.cstate = htons (GMT_get_cstate (t));
+ msg.estate = htons (42);
- LOG (GNUNET_ERROR_TYPE_INFO,
- "* sending info about tunnel %s\n",
- GNUNET_i2s (&msg->owner));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n",
+ GNUNET_i2s (peer));
GNUNET_SERVER_notification_context_unicast (nc, client,
- &msg->header, GNUNET_NO);
+ &msg.header, GNUNET_NO);
return GNUNET_YES;
}
Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c 2014-01-06 04:36:42 UTC (rev 31794)
+++ gnunet/src/mesh/mesh_api.c 2014-01-06 04:38:54 UTC (rev 31795)
@@ -1034,28 +1034,34 @@
process_get_tunnels (struct GNUNET_MESH_Handle *h,
const struct GNUNET_MessageHeader *message)
{
- struct GNUNET_PeerIdentity *id;
+ struct GNUNET_MESH_LocalInfoTunnel *msg;
uint16_t size;
- unsigned int i;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get Tunnels messasge received\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnels messasge received\n");
if (NULL == h->tunnels_cb)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ignored\n");
return;
}
size = ntohs (message->size);
- size /= sizeof (struct GNUNET_PeerIdentity);
- id = (struct GNUNET_PeerIdentity *) &message[1];
+ if (sizeof (struct GNUNET_MESH_LocalInfoTunnel) > size)
+ {
+ h->tunnels_cb (h->tunnel_cls, NULL, 0, 0, 0, 0);
+ h->tunnels_cb = NULL;
+ h->tunnels_cls = NULL;
+ return;
+ }
- for (i = 0; i < size; i++)
- h->tunnels_cb (h->tunnels_cls, &id[i]);
- h->tunnels_cb (h->tunnels_cls, NULL);
+ msg = (struct GNUNET_MESH_LocalInfoTunnel *) message;
+ h->tunnels_cb (h->tunnel_cls,
+ &msg->destination,
+ ntohl (msg->channels),
+ ntohl (msg->connections),
+ ntohl (msg->estate),
+ ntohl (msg->cstate));
- h->tunnels_cb = NULL;
- h->tunnels_cls = NULL;
}
@@ -1066,44 +1072,49 @@
* @param h Mesh handle.
* @param message Message itself.
*/
-// static void
-// process_show_channel (struct GNUNET_MESH_Handle *h,
-// const struct GNUNET_MessageHeader *message)
-// {
-// struct GNUNET_MESH_LocalInfo *msg;
-// size_t esize;
-//
-// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Show Channel messasge received\n");
-//
-// if (NULL == h->channel_cb)
-// {
-// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n");
-// return;
-// }
-//
-// /* Verify message sanity */
-// msg = (struct GNUNET_MESH_LocalInfo *) message;
-// esize = sizeof (struct GNUNET_MESH_LocalInfo);
-// if (ntohs (message->size) != esize)
-// {
-// GNUNET_break_op (0);
-// GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-// "Show channel message: size %hu - expected %u\n",
-// ntohs (message->size),
-// esize);
-//
-// h->channel_cb (h->channel_cls, NULL, NULL);
-// h->channel_cb = NULL;
-// h->channel_cls = NULL;
-//
-// return;
-// }
-//
-// h->channel_cb (h->channel_cls,
-// &msg->destination,
-// &msg->owner);
-// }
+static void
+process_get_tunnel (struct GNUNET_MESH_Handle *h,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct GNUNET_MESH_LocalInfoTunnel *msg;
+ size_t esize;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get Tunnel messasge received\n");
+
+ if (NULL == h->tunnel_cb)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n");
+ return;
+ }
+
+ /* Verify message sanity */
+ msg = (struct GNUNET_MESH_LocalInfoTunnel *) message;
+ esize = sizeof (struct GNUNET_MESH_LocalInfo);
+ if (ntohs (message->size) != esize)
+ {
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Get Tunnel message: size %hu - expected %u\n",
+ ntohs (message->size),
+ esize);
+
+ h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0);
+ h->tunnel_cb = NULL;
+ h->tunnel_cls = NULL;
+
+ return;
+ }
+
+ h->tunnel_cb (h->tunnel_cls,
+ &msg->destination,
+ ntohl (msg->channels),
+ ntohl (msg->connections),
+ ntohl (msg->estate),
+ ntohl (msg->cstate));
+ h->tunnel_cb = NULL;
+ h->tunnel_cls = NULL;
+}
+
/**
* Function to process all messages received from the service
*
@@ -1153,6 +1164,9 @@
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS:
process_get_tunnels (h, msg);
break;
+ case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL:
+ process_get_tunnel (h, msg);
+ break;
// case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
// process_show_channel (h, msg);
// break;
@@ -1161,7 +1175,7 @@
LOG (GNUNET_ERROR_TYPE_WARNING,
"unsolicited message form service (type %s)\n",
GM_m2s (ntohs (msg->type)));
- }
+ } FPRINTF (stdout, "\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n");
if (GNUNET_YES == h->in_receive)
{
@@ -1435,6 +1449,8 @@
case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS:
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
+ case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL:
+ case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS:
break;
default:
GNUNET_break (0);
@@ -1756,7 +1772,7 @@
h->tunnels_cb = NULL;
cls = h->tunnels_cls;
h->tunnels_cls = NULL;
-
+
return cls;
}
@@ -1780,7 +1796,7 @@
void
GNUNET_MESH_get_tunnel (struct GNUNET_MESH_Handle *h,
const struct GNUNET_PeerIdentity *id,
- GNUNET_MESH_TunnelsCB callback,
+ GNUNET_MESH_TunnelCB callback,
void *callback_cls)
{
struct GNUNET_MESH_LocalInfo msg;
@@ -1790,6 +1806,8 @@
msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
msg.destination = *id;
send_packet (h, &msg.header, NULL);
+ h->tunnel_cb = callback;
+ h->tunnel_cls = callback_cls;
}
@@ -1818,7 +1836,7 @@
msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL);
msg.owner = *initiator;
msg.channel_id = htonl (channel_number);
- msg.reserved = 0;
+// msg.reserved = 0;
send_packet (h, &msg.header, NULL);
h->channel_cb = callback;
h->channel_cls = callback_cls;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31795 - gnunet/src/mesh,
gnunet <=