aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_local.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-01-06 05:18:30 +0000
committerBart Polot <bart@net.in.tum.de>2014-01-06 05:18:30 +0000
commit0ccd26a719e7f197ccfb053b9517162f51c9da2c (patch)
tree49b75cea3355768ea27778da602bdd234cacff21 /src/mesh/gnunet-service-mesh_local.c
parent532ac9a55e3f2f6eaea7f6b6c38cd6a7bdbb3e6a (diff)
downloadgnunet-0ccd26a719e7f197ccfb053b9517162f51c9da2c.tar.gz
gnunet-0ccd26a719e7f197ccfb053b9517162f51c9da2c.zip
- more tunnels info for CLI
Diffstat (limited to 'src/mesh/gnunet-service-mesh_local.c')
-rw-r--r--src/mesh/gnunet-service-mesh_local.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index 8fc01f929..0470d982d 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -298,7 +298,8 @@ handle_new_client (void *cls, struct GNUNET_SERVER_Client *client,
298 uint32_t *p; 298 uint32_t *p;
299 unsigned int i; 299 unsigned int i;
300 300
301 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\nnew client connected %p\n", client); 301 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
302 LOG (GNUNET_ERROR_TYPE_DEBUG, "new client connected %p\n", client);
302 303
303 /* Check data sanity */ 304 /* Check data sanity */
304 size = ntohs (message->size) - sizeof (struct GNUNET_MESH_ClientConnect); 305 size = ntohs (message->size) - sizeof (struct GNUNET_MESH_ClientConnect);
@@ -581,7 +582,7 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client,
581/** 582/**
582 * Iterator over all tunnels to send a monitoring client info about each tunnel. 583 * Iterator over all tunnels to send a monitoring client info about each tunnel.
583 * 584 *
584 * @param cls Closure (client handle). 585 * @param cls Closure ().
585 * @param peer Peer ID (tunnel remote peer). 586 * @param peer Peer ID (tunnel remote peer).
586 * @param value Tunnel info. 587 * @param value Tunnel info.
587 * 588 *
@@ -599,10 +600,10 @@ monitor_all_tunnels_iterator (void *cls,
599 msg.header.size = htons (sizeof (msg)); 600 msg.header.size = htons (sizeof (msg));
600 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); 601 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
601 msg.destination = *peer; 602 msg.destination = *peer;
602 msg.channels = htons (42); 603 msg.channels = htonl (GMT_count_channels (t));
603 msg.connections = htons (42); 604 msg.connections = htonl (GMT_count_connections (t));
604 msg.cstate = htons (GMT_get_cstate (t)); 605 msg.cstate = htons ((uint16_t) GMT_get_cstate (t));
605 msg.estate = htons (42); 606 msg.estate = htons ((uint16_t) GMT_get_estate (t));
606 607
607 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n", 608 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n",
608 GNUNET_i2s (peer)); 609 GNUNET_i2s (peer));
@@ -625,8 +626,7 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
625 const struct GNUNET_MessageHeader *message) 626 const struct GNUNET_MessageHeader *message)
626{ 627{
627 struct MeshClient *c; 628 struct MeshClient *c;
628 size_t size; 629 struct GNUNET_MessageHeader reply;
629 struct GNUNET_MessageHeader *reply;
630 630
631 /* Sanity check for client registration */ 631 /* Sanity check for client registration */
632 if (NULL == (c = GML_client_get (client))) 632 if (NULL == (c = GML_client_get (client)))
@@ -636,21 +636,17 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
636 return; 636 return;
637 } 637 }
638 638
639 LOG (GNUNET_ERROR_TYPE_INFO, "Received get tunnels request from client %u\n", 639 LOG (GNUNET_ERROR_TYPE_DEBUG,
640 c->id); 640 "Received get tunnels request from client %u (%p)\n",
641 c->id, client);
641 642
642 size = GMT_count_all () + 1; /* Last one is all \0 to mark 'end' */ 643 GMT_iterate_all (client, monitor_all_tunnels_iterator);
643 size *= sizeof (struct GNUNET_PeerIdentity); 644 reply.size = htons (sizeof (reply));
644 size += sizeof (*reply); 645 reply.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
645 reply = GNUNET_malloc (size); 646 GNUNET_SERVER_notification_context_unicast (nc, client, &reply, GNUNET_NO);
646 GMT_iterate_all (reply, monitor_all_tunnels_iterator);
647 reply->size = htons (size);
648 reply->type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
649 GNUNET_SERVER_notification_context_unicast (nc, client, reply, GNUNET_NO);
650 647
651 LOG (GNUNET_ERROR_TYPE_INFO, 648 LOG (GNUNET_ERROR_TYPE_DEBUG,
652 "Get tunnels request from client %u completed\n", 649 "Get tunnels request from client %u completed\n", c->id);
653 c->id);
654 GNUNET_SERVER_receive_done (client, GNUNET_OK); 650 GNUNET_SERVER_receive_done (client, GNUNET_OK);
655} 651}
656 652