diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-01-06 05:18:30 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-01-06 05:18:30 +0000 |
commit | 0ccd26a719e7f197ccfb053b9517162f51c9da2c (patch) | |
tree | 49b75cea3355768ea27778da602bdd234cacff21 /src | |
parent | 532ac9a55e3f2f6eaea7f6b6c38cd6a7bdbb3e6a (diff) | |
download | gnunet-0ccd26a719e7f197ccfb053b9517162f51c9da2c.tar.gz gnunet-0ccd26a719e7f197ccfb053b9517162f51c9da2c.zip |
- more tunnels info for CLI
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-mesh.c | 20 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_local.c | 38 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.c | 22 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.h | 10 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 4 |
5 files changed, 63 insertions, 31 deletions
diff --git a/src/mesh/gnunet-mesh.c b/src/mesh/gnunet-mesh.c index eaa9c09fd..afdd94a9c 100644 --- a/src/mesh/gnunet-mesh.c +++ b/src/mesh/gnunet-mesh.c | |||
@@ -122,6 +122,7 @@ static void | |||
122 | shutdown_task (void *cls, | 122 | shutdown_task (void *cls, |
123 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 123 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
124 | { | 124 | { |
125 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | ||
125 | if (NULL != ch) | 126 | if (NULL != ch) |
126 | { | 127 | { |
127 | GNUNET_MESH_channel_destroy (ch); | 128 | GNUNET_MESH_channel_destroy (ch); |
@@ -439,10 +440,18 @@ tunnels_callback (void *cls, | |||
439 | const struct GNUNET_PeerIdentity *peer, | 440 | const struct GNUNET_PeerIdentity *peer, |
440 | unsigned int channels, | 441 | unsigned int channels, |
441 | unsigned int connections, | 442 | unsigned int connections, |
442 | unsigned int estate, | 443 | uint16_t estate, |
443 | unsigned int cstate) | 444 | uint16_t cstate) |
444 | { | 445 | { |
445 | FPRINTF (stdout, "%s [%u, %u] CH: %u, C: %u\n", | 446 | if (NULL == peer) |
447 | { | ||
448 | if (GNUNET_YES != monitor_connections) | ||
449 | { | ||
450 | GNUNET_SCHEDULER_shutdown(); | ||
451 | } | ||
452 | return; | ||
453 | } | ||
454 | FPRINTF (stdout, "%s [ENC: %u, CON: %u] CHs: %u, CONNs: %u\n", | ||
446 | GNUNET_i2s_full (peer), estate, cstate, channels, connections); | 455 | GNUNET_i2s_full (peer), estate, cstate, channels, connections); |
447 | } | 456 | } |
448 | 457 | ||
@@ -483,15 +492,12 @@ tunnel_callback (void *cls, | |||
483 | static void | 492 | static void |
484 | get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 493 | get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
485 | { | 494 | { |
495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | ||
486 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 496 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
487 | { | 497 | { |
488 | return; | 498 | return; |
489 | } | 499 | } |
490 | GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL); | 500 | GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL); |
491 | if (GNUNET_YES != monitor_connections) | ||
492 | { | ||
493 | GNUNET_SCHEDULER_shutdown(); | ||
494 | } | ||
495 | } | 501 | } |
496 | 502 | ||
497 | 503 | ||
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 | ||
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 3224c9939..07375a43c 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c | |||
@@ -2183,6 +2183,24 @@ GMT_get_cstate (struct MeshTunnel3 *t) | |||
2183 | 2183 | ||
2184 | 2184 | ||
2185 | /** | 2185 | /** |
2186 | * Get the encryption state of a tunnel. | ||
2187 | * | ||
2188 | * @param t Tunnel. | ||
2189 | * | ||
2190 | * @return Tunnel's encryption state. | ||
2191 | */ | ||
2192 | enum MeshTunnel3EState | ||
2193 | GMT_get_estate (struct MeshTunnel3 *t) | ||
2194 | { | ||
2195 | if (NULL == t) | ||
2196 | { | ||
2197 | GNUNET_assert (0); | ||
2198 | return (enum MeshTunnel3EState) -1; | ||
2199 | } | ||
2200 | return t->estate; | ||
2201 | } | ||
2202 | |||
2203 | /** | ||
2186 | * Get the maximum buffer space for a tunnel towards a local client. | 2204 | * Get the maximum buffer space for a tunnel towards a local client. |
2187 | * | 2205 | * |
2188 | * @param t Tunnel. | 2206 | * @param t Tunnel. |
@@ -2387,7 +2405,9 @@ GMT_send_connection_acks (struct MeshTunnel3 *t) | |||
2387 | /* Authorize connections to send more data */ | 2405 | /* Authorize connections to send more data */ |
2388 | to_allow = buffer; /* - allowed; */ | 2406 | to_allow = buffer; /* - allowed; */ |
2389 | 2407 | ||
2390 | for (iter = t->connection_head; NULL != iter && to_allow > 0; iter = iter->next) | 2408 | for (iter = t->connection_head; |
2409 | NULL != iter && to_allow > 0; | ||
2410 | iter = iter->next) | ||
2391 | { | 2411 | { |
2392 | allow_per_connection = to_allow/cs; | 2412 | allow_per_connection = to_allow/cs; |
2393 | to_allow -= allow_per_connection; | 2413 | to_allow -= allow_per_connection; |
diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index 19431e346..e38d313cb 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h | |||
@@ -326,6 +326,16 @@ enum MeshTunnel3CState | |||
326 | GMT_get_cstate (struct MeshTunnel3 *t); | 326 | GMT_get_cstate (struct MeshTunnel3 *t); |
327 | 327 | ||
328 | /** | 328 | /** |
329 | * Get the encryption state of a tunnel. | ||
330 | * | ||
331 | * @param t Tunnel. | ||
332 | * | ||
333 | * @return Tunnel's encryption state. | ||
334 | */ | ||
335 | enum MeshTunnel3EState | ||
336 | GMT_get_estate (struct MeshTunnel3 *t); | ||
337 | |||
338 | /** | ||
329 | * Get the maximum buffer space for a tunnel towards a local client. | 339 | * Get the maximum buffer space for a tunnel towards a local client. |
330 | * | 340 | * |
331 | * @param t Tunnel. | 341 | * @param t Tunnel. |
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 5f3f2da51..6d16be08e 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -1059,8 +1059,8 @@ process_get_tunnels (struct GNUNET_MESH_Handle *h, | |||
1059 | &msg->destination, | 1059 | &msg->destination, |
1060 | ntohl (msg->channels), | 1060 | ntohl (msg->channels), |
1061 | ntohl (msg->connections), | 1061 | ntohl (msg->connections), |
1062 | ntohl (msg->estate), | 1062 | ntohs (msg->estate), |
1063 | ntohl (msg->cstate)); | 1063 | ntohs (msg->cstate)); |
1064 | 1064 | ||
1065 | } | 1065 | } |
1066 | 1066 | ||