diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-12-28 14:30:51 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-12-28 14:30:51 +0000 |
commit | 4493d69b8625d799167e82edc1aca52617ba913d (patch) | |
tree | 288f4fc16c185c4d62b8680302014ab58badd90a /src/mesh/gnunet-service-mesh_local.c | |
parent | c4cba40c252dd423fc4876c9def15f0f8efe51f3 (diff) | |
download | gnunet-4493d69b8625d799167e82edc1aca52617ba913d.tar.gz gnunet-4493d69b8625d799167e82edc1aca52617ba913d.zip |
- Add some of the tunnel introscpecion back
Diffstat (limited to 'src/mesh/gnunet-service-mesh_local.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_local.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c index fa54fafa6..82743c892 100644 --- a/src/mesh/gnunet-service-mesh_local.c +++ b/src/mesh/gnunet-service-mesh_local.c | |||
@@ -30,6 +30,9 @@ | |||
30 | #include "gnunet-service-mesh_local.h" | 30 | #include "gnunet-service-mesh_local.h" |
31 | #include "gnunet-service-mesh_channel.h" | 31 | #include "gnunet-service-mesh_channel.h" |
32 | 32 | ||
33 | /* INFO DEBUG */ | ||
34 | #include "gnunet-service-mesh_tunnel.h" | ||
35 | |||
33 | #define LOG(level, ...) GNUNET_log_from(level,"mesh-loc",__VA_ARGS__) | 36 | #define LOG(level, ...) GNUNET_log_from(level,"mesh-loc",__VA_ARGS__) |
34 | 37 | ||
35 | /******************************************************************************/ | 38 | /******************************************************************************/ |
@@ -575,41 +578,41 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
575 | } | 578 | } |
576 | 579 | ||
577 | 580 | ||
578 | /* | 581 | /** |
579 | * Iterator over all tunnels to send a monitoring client info about each tunnel. | 582 | * Iterator over all tunnels to send a monitoring client info about each tunnel. |
580 | * | 583 | * |
581 | * @param cls Closure (client handle). | 584 | * @param cls Closure (client handle). |
582 | * @param key Key (hashed tunnel ID, unused). | 585 | * @param peer Peer ID (tunnel remote peer). |
583 | * @param value Tunnel info. | 586 | * @param value Tunnel info. |
584 | * | 587 | * |
585 | * @return #GNUNET_YES, to keep iterating. | 588 | * @return #GNUNET_YES, to keep iterating. |
586 | */ | 589 | */ |
587 | // static int | 590 | static int |
588 | // monitor_all_tunnels_iterator (void *cls, | 591 | monitor_all_tunnels_iterator (void *cls, |
589 | // const struct GNUNET_HashCode * key, | 592 | const struct GNUNET_PeerIdentity * peer, |
590 | // void *value) | 593 | void *value) |
591 | // { | 594 | { |
592 | // struct GNUNET_SERVER_Client *client = cls; | 595 | struct GNUNET_SERVER_Client *client = cls; |
593 | // struct MeshChannel *ch = value; | 596 | struct MeshChannel *ch = value; |
594 | // struct GNUNET_MESH_LocalMonitor *msg; | 597 | struct GNUNET_MESH_LocalInfo *msg; |
595 | // | 598 | |
596 | // msg = GNUNET_new (struct GNUNET_MESH_LocalMonitor); | 599 | msg = GNUNET_new (struct GNUNET_MESH_LocalInfo); |
597 | // msg->channel_id = htonl (ch->gid); | 600 | msg->channel_id = htonl (GMCH_get_id (ch)); |
598 | // msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor)); | 601 | msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalInfo)); |
599 | // msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); | 602 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); |
600 | // | 603 | |
601 | // LOG (GNUNET_ERROR_TYPE_INFO, | 604 | LOG (GNUNET_ERROR_TYPE_INFO, |
602 | // "* sending info about tunnel %s\n", | 605 | "* sending info about tunnel %s\n", |
603 | // GNUNET_i2s (&msg->owner)); | 606 | GNUNET_i2s (&msg->owner)); |
604 | // | 607 | |
605 | // GNUNET_SERVER_notification_context_unicast (nc, client, | 608 | GNUNET_SERVER_notification_context_unicast (nc, client, |
606 | // &msg->header, GNUNET_NO); | 609 | &msg->header, GNUNET_NO); |
607 | // return GNUNET_YES; | 610 | return GNUNET_YES; |
608 | // } | 611 | } |
609 | 612 | ||
610 | 613 | ||
611 | /** | 614 | /** |
612 | * Handler for client's MONITOR request. | 615 | * Handler for client's INFO TUNNELS request. |
613 | * | 616 | * |
614 | * @param cls Closure (unused). | 617 | * @param cls Closure (unused). |
615 | * @param client Identification of the client. | 618 | * @param client Identification of the client. |
@@ -620,6 +623,8 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client, | |||
620 | const struct GNUNET_MessageHeader *message) | 623 | const struct GNUNET_MessageHeader *message) |
621 | { | 624 | { |
622 | struct MeshClient *c; | 625 | struct MeshClient *c; |
626 | size_t size; | ||
627 | struct GNUNET_MessageHeader *reply; | ||
623 | 628 | ||
624 | /* Sanity check for client registration */ | 629 | /* Sanity check for client registration */ |
625 | if (NULL == (c = GML_client_get (client))) | 630 | if (NULL == (c = GML_client_get (client))) |
@@ -629,12 +634,18 @@ handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client, | |||
629 | return; | 634 | return; |
630 | } | 635 | } |
631 | 636 | ||
632 | LOG (GNUNET_ERROR_TYPE_INFO, | 637 | LOG (GNUNET_ERROR_TYPE_INFO, "Received get tunnels request from client %u\n", |
633 | "Received get tunnels request from client %u\n", | 638 | c->id); |
634 | c->id); | 639 | |
635 | // GNUNET_CONTAINER_multihashmap_iterate (tunnels, | 640 | size = GMT_count_all () + 1; /* Last one is all \0 to mark 'end' */ |
636 | // monitor_all_tunnels_iterator, | 641 | size *= sizeof (struct GNUNET_PeerIdentity); |
637 | // client); | 642 | size += sizeof (*reply); |
643 | reply = GNUNET_malloc (size); | ||
644 | GMT_iterate_all (reply, monitor_all_tunnels_iterator); | ||
645 | reply->size = htons (size); | ||
646 | reply->type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); | ||
647 | GNUNET_SERVER_notification_context_unicast (nc, client, reply, GNUNET_NO); | ||
648 | |||
638 | LOG (GNUNET_ERROR_TYPE_INFO, | 649 | LOG (GNUNET_ERROR_TYPE_INFO, |
639 | "Get tunnels request from client %u completed\n", | 650 | "Get tunnels request from client %u completed\n", |
640 | c->id); | 651 | c->id); |
@@ -653,8 +664,8 @@ void | |||
653 | handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | 664 | handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, |
654 | const struct GNUNET_MessageHeader *message) | 665 | const struct GNUNET_MessageHeader *message) |
655 | { | 666 | { |
656 | const struct GNUNET_MESH_LocalMonitor *msg; | 667 | const struct GNUNET_MESH_LocalInfo *msg; |
657 | struct GNUNET_MESH_LocalMonitor *resp; | 668 | struct GNUNET_MESH_LocalInfo *resp; |
658 | struct MeshClient *c; | 669 | struct MeshClient *c; |
659 | struct MeshChannel *ch; | 670 | struct MeshChannel *ch; |
660 | 671 | ||
@@ -666,7 +677,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
666 | return; | 677 | return; |
667 | } | 678 | } |
668 | 679 | ||
669 | msg = (struct GNUNET_MESH_LocalMonitor *) message; | 680 | msg = (struct GNUNET_MESH_LocalInfo *) message; |
670 | LOG (GNUNET_ERROR_TYPE_INFO, | 681 | LOG (GNUNET_ERROR_TYPE_INFO, |
671 | "Received tunnel info request from client %u for tunnel %s[%X]\n", | 682 | "Received tunnel info request from client %u for tunnel %s[%X]\n", |
672 | c->id, | 683 | c->id, |
@@ -677,7 +688,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
677 | if (NULL == ch) | 688 | if (NULL == ch) |
678 | { | 689 | { |
679 | /* We don't know the tunnel */ | 690 | /* We don't know the tunnel */ |
680 | struct GNUNET_MESH_LocalMonitor warn; | 691 | struct GNUNET_MESH_LocalInfo warn; |
681 | 692 | ||
682 | warn = *msg; | 693 | warn = *msg; |
683 | GNUNET_SERVER_notification_context_unicast (nc, client, | 694 | GNUNET_SERVER_notification_context_unicast (nc, client, |
@@ -688,9 +699,9 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
688 | } | 699 | } |
689 | 700 | ||
690 | /* Initialize context */ | 701 | /* Initialize context */ |
691 | resp = GNUNET_new (struct GNUNET_MESH_LocalMonitor); | 702 | resp = GNUNET_new (struct GNUNET_MESH_LocalInfo); |
692 | *resp = *msg; | 703 | *resp = *msg; |
693 | resp->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor)); | 704 | resp->header.size = htons (sizeof (struct GNUNET_MESH_LocalInfo)); |
694 | GNUNET_SERVER_notification_context_unicast (nc, c->handle, | 705 | GNUNET_SERVER_notification_context_unicast (nc, c->handle, |
695 | &resp->header, GNUNET_NO); | 706 | &resp->header, GNUNET_NO); |
696 | GNUNET_free (resp); | 707 | GNUNET_free (resp); |
@@ -717,7 +728,7 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = { | |||
717 | {&handle_get_tunnels, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS, | 728 | {&handle_get_tunnels, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS, |
718 | sizeof (struct GNUNET_MessageHeader)}, | 729 | sizeof (struct GNUNET_MessageHeader)}, |
719 | {&handle_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL, | 730 | {&handle_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL, |
720 | sizeof (struct GNUNET_MESH_LocalMonitor)}, | 731 | sizeof (struct GNUNET_MESH_LocalInfo)}, |
721 | {NULL, NULL, 0, 0} | 732 | {NULL, NULL, 0, 0} |
722 | }; | 733 | }; |
723 | 734 | ||