shutdown_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
if (NULL != ch)
{
GNUNET_MESH_channel_destroy (ch);
const struct GNUNET_PeerIdentity *peer,
unsigned int channels,
unsigned int connections,
- unsigned int estate,
- unsigned int cstate)
+ uint16_t estate,
+ uint16_t cstate)
{
- FPRINTF (stdout, "%s [%u, %u] CH: %u, C: %u\n",
+ if (NULL == peer)
+ {
+ if (GNUNET_YES != monitor_connections)
+ {
+ GNUNET_SCHEDULER_shutdown();
+ }
+ return;
+ }
+ FPRINTF (stdout, "%s [ENC: %u, CON: %u] CHs: %u, CONNs: %u\n",
GNUNET_i2s_full (peer), estate, cstate, channels, connections);
}
static void
get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
return;
}
GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL);
- if (GNUNET_YES != monitor_connections)
- {
- GNUNET_SCHEDULER_shutdown();
- }
}
uint32_t *p;
unsigned int i;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\nnew client connected %p\n", client);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "new client connected %p\n", client);
/* Check data sanity */
size = ntohs (message->size) - sizeof (struct GNUNET_MESH_ClientConnect);
/**
* Iterator over all tunnels to send a monitoring client info about each tunnel.
*
- * @param cls Closure (client handle).
+ * @param cls Closure ().
* @param peer Peer ID (tunnel remote peer).
* @param value Tunnel info.
*
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);
+ msg.channels = htonl (GMT_count_channels (t));
+ msg.connections = htonl (GMT_count_connections (t));
+ msg.cstate = htons ((uint16_t) GMT_get_cstate (t));
+ msg.estate = htons ((uint16_t) GMT_get_estate (t));
LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n",
GNUNET_i2s (peer));
const struct GNUNET_MessageHeader *message)
{
struct MeshClient *c;
- size_t size;
- struct GNUNET_MessageHeader *reply;
+ struct GNUNET_MessageHeader reply;
/* Sanity check for client registration */
if (NULL == (c = GML_client_get (client)))
return;
}
- LOG (GNUNET_ERROR_TYPE_INFO, "Received get tunnels request from client %u\n",
- c->id);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received get tunnels request from client %u (%p)\n",
+ c->id, client);
- size = GMT_count_all () + 1; /* Last one is all \0 to mark 'end' */
- size *= sizeof (struct GNUNET_PeerIdentity);
- size += sizeof (*reply);
- reply = GNUNET_malloc (size);
- GMT_iterate_all (reply, monitor_all_tunnels_iterator);
- reply->size = htons (size);
- reply->type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
- GNUNET_SERVER_notification_context_unicast (nc, client, reply, GNUNET_NO);
+ GMT_iterate_all (client, monitor_all_tunnels_iterator);
+ reply.size = htons (sizeof (reply));
+ reply.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
+ GNUNET_SERVER_notification_context_unicast (nc, client, &reply, GNUNET_NO);
- LOG (GNUNET_ERROR_TYPE_INFO,
- "Get tunnels request from client %u completed\n",
- c->id);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Get tunnels request from client %u completed\n", c->id);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
}
+/**
+ * Get the encryption state of a tunnel.
+ *
+ * @param t Tunnel.
+ *
+ * @return Tunnel's encryption state.
+ */
+enum MeshTunnel3EState
+GMT_get_estate (struct MeshTunnel3 *t)
+{
+ if (NULL == t)
+ {
+ GNUNET_assert (0);
+ return (enum MeshTunnel3EState) -1;
+ }
+ return t->estate;
+}
+
/**
* Get the maximum buffer space for a tunnel towards a local client.
*
/* Authorize connections to send more data */
to_allow = buffer; /* - allowed; */
- for (iter = t->connection_head; NULL != iter && to_allow > 0; iter = iter->next)
+ for (iter = t->connection_head;
+ NULL != iter && to_allow > 0;
+ iter = iter->next)
{
allow_per_connection = to_allow/cs;
to_allow -= allow_per_connection;