aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_local.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-01-13 19:33:49 +0000
committerBart Polot <bart@net.in.tum.de>2014-01-13 19:33:49 +0000
commitbcc04f0a5babd8283ff50c5dd13e0afccdb2e5f4 (patch)
treea46bb0a1488ebd5ab8e979a454d767d0d3b3dd49 /src/mesh/gnunet-service-mesh_local.c
parent1257490cb630ade315a196a724d0233e662afb2c (diff)
downloadgnunet-bcc04f0a5babd8283ff50c5dd13e0afccdb2e5f4.tar.gz
gnunet-bcc04f0a5babd8283ff50c5dd13e0afccdb2e5f4.zip
- various CLI fixes
Diffstat (limited to 'src/mesh/gnunet-service-mesh_local.c')
-rw-r--r--src/mesh/gnunet-service-mesh_local.c64
1 files changed, 47 insertions, 17 deletions
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index 0470d982d..11812de79 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -651,8 +651,19 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
651} 651}
652 652
653 653
654static void
655iter_connection (void *cls, struct MeshConnection *c)
656{
657}
658
659static void
660iter_channel (void *cls, struct MeshChannel *ch)
661{
662}
663
664
654/** 665/**
655 * Handler for client's MONITOR_TUNNEL request. 666 * Handler for client's SHOW_TUNNEL request.
656 * 667 *
657 * @param cls Closure (unused). 668 * @param cls Closure (unused).
658 * @param client Identification of the client. 669 * @param client Identification of the client.
@@ -663,9 +674,12 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
663 const struct GNUNET_MessageHeader *message) 674 const struct GNUNET_MessageHeader *message)
664{ 675{
665 const struct GNUNET_MESH_LocalInfo *msg; 676 const struct GNUNET_MESH_LocalInfo *msg;
666 struct GNUNET_MESH_LocalInfo *resp; 677 struct GNUNET_MESH_LocalInfoTunnel *resp;
667 struct MeshClient *c; 678 struct MeshClient *c;
668 struct MeshChannel *ch; 679 struct MeshTunnel3 *t;
680 unsigned int ch_n;
681 unsigned int c_n;
682 size_t size;
669 683
670 /* Sanity check for client registration */ 684 /* Sanity check for client registration */
671 if (NULL == (c = GML_client_get (client))) 685 if (NULL == (c = GML_client_get (client)))
@@ -677,18 +691,23 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
677 691
678 msg = (struct GNUNET_MESH_LocalInfo *) message; 692 msg = (struct GNUNET_MESH_LocalInfo *) message;
679 LOG (GNUNET_ERROR_TYPE_INFO, 693 LOG (GNUNET_ERROR_TYPE_INFO,
680 "Received tunnel info request from client %u for tunnel %s[%X]\n", 694 "Received tunnel info request from client %u for tunnel %s\n",
681 c->id, 695 c->id, GNUNET_i2s_full(&msg->peer));
682 &msg->owner, 696
683 ntohl (msg->channel_id)); 697 t = GMP_get_tunnel (GMP_get (&msg->peer));
684// ch = channel_get (&msg->owner, ntohl (msg->channel_id)); 698 if (NULL == t)
685 ch = NULL; // FIXME
686 if (NULL == ch)
687 { 699 {
688 /* We don't know the tunnel */ 700 /* We don't know the tunnel */
689 struct GNUNET_MESH_LocalInfo warn; 701 struct GNUNET_MESH_LocalInfoTunnel warn;
702
703 warn.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
704 warn.header.size = htons (sizeof (warn));
705 warn.destination = msg->peer;
706 warn.channels = htonl (0);
707 warn.connections = htonl (0);
708 warn.cstate = htons (0);
709 warn.estate = htons (0);
690 710
691 warn = *msg;
692 GNUNET_SERVER_notification_context_unicast (nc, client, 711 GNUNET_SERVER_notification_context_unicast (nc, client,
693 &warn.header, 712 &warn.header,
694 GNUNET_NO); 713 GNUNET_NO);
@@ -697,16 +716,27 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
697 } 716 }
698 717
699 /* Initialize context */ 718 /* Initialize context */
700 resp = GNUNET_new (struct GNUNET_MESH_LocalInfo); 719 ch_n = GMT_count_channels (t);
701 *resp = *msg; 720 c_n = GMT_count_connections (t);
702 resp->header.size = htons (sizeof (struct GNUNET_MESH_LocalInfo)); 721
722 size = sizeof (struct GNUNET_MESH_LocalInfo);
723 size += c_n * sizeof (struct GNUNET_HashCode);
724 size += ch_n * sizeof (uint32_t);
725
726 resp = GNUNET_malloc (size);
727 resp->header.size = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
728 resp->header.size = htons (size);
729 GMT_iterate_connections (t, &iter_connection, resp);
730 GMT_iterate_channels (t, &iter_channel, resp);
731 resp->cstate = htons (GMT_get_cstate (t));
732 resp->estate = htons (GMT_get_estate (t));
703 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 733 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
704 &resp->header, GNUNET_NO); 734 &resp->header, GNUNET_NO);
705 GNUNET_free (resp); 735 GNUNET_free (resp);
706 736
707 LOG (GNUNET_ERROR_TYPE_INFO, 737 LOG (GNUNET_ERROR_TYPE_INFO,
708 "Monitor tunnel request from client %u completed\n", 738 "Show tunnel request from client %u completed\n",
709 c->id); 739 c->id);
710 GNUNET_SERVER_receive_done (client, GNUNET_OK); 740 GNUNET_SERVER_receive_done (client, GNUNET_OK);
711} 741}
712 742