diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-07 16:07:48 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-07 16:07:48 +0000 |
commit | 230c72bb1a9aae87bbbd0f1da505f33fc42b1b99 (patch) | |
tree | e80c4b8028828fc9f6d4bf89ff1efda86fb07994 /src/transport/gnunet-service-transport_clients.c | |
parent | 381046a7d5c92f5ec1b9bf4566eecacfde269099 (diff) | |
download | gnunet-230c72bb1a9aae87bbbd0f1da505f33fc42b1b99.tar.gz gnunet-230c72bb1a9aae87bbbd0f1da505f33fc42b1b99.zip |
porting gnunet-transport-list-connections to binary address
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 140b15454..8676f335e 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -625,18 +625,42 @@ clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, | |||
625 | * @param address the resolved name, NULL to indicate the last response | 625 | * @param address the resolved name, NULL to indicate the last response |
626 | */ | 626 | */ |
627 | static void | 627 | static void |
628 | transmit_address_to_client (void *cls, const char *address) | 628 | transmit_address_to_client (void *cls, const char *buf) |
629 | { | 629 | { |
630 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 630 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
631 | 631 | ||
632 | if (NULL == address) | 632 | if (NULL == buf) |
633 | { | 633 | { |
634 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 634 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, |
635 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | 635 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); |
636 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | 636 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); |
637 | return; | 637 | return; |
638 | } | 638 | } |
639 | GNUNET_SERVER_transmit_context_append_data (tc, address, strlen (address) + 1, | 639 | GNUNET_SERVER_transmit_context_append_data (tc, buf, strlen (buf + 1), |
640 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
641 | } | ||
642 | |||
643 | |||
644 | /** | ||
645 | * Take the given address and append it to the set of results sent back to | ||
646 | * the client. | ||
647 | * | ||
648 | * @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*') | ||
649 | * @param address the resolved name, NULL to indicate the last response | ||
650 | */ | ||
651 | static void | ||
652 | transmit_binary_to_client (void *cls, void *buf, size_t size) | ||
653 | { | ||
654 | struct GNUNET_SERVER_TransmitContext *tc = cls; | ||
655 | |||
656 | if (NULL == buf) | ||
657 | { | ||
658 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | ||
659 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
660 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | ||
661 | return; | ||
662 | } | ||
663 | GNUNET_SERVER_transmit_context_append_data (tc, buf, size, | ||
640 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | 664 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); |
641 | } | 665 | } |
642 | 666 | ||
@@ -781,18 +805,22 @@ clients_handle_peer_address_lookup (void *cls, | |||
781 | * @param ats_count number of entries in ats (excluding 0-termination) | 805 | * @param ats_count number of entries in ats (excluding 0-termination) |
782 | */ | 806 | */ |
783 | static void | 807 | static void |
784 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *neighbour, | 808 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, |
785 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 809 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
786 | uint32_t ats_count) | 810 | uint32_t ats_count) |
787 | { | 811 | { |
788 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 812 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
789 | char *addr_buf; | 813 | struct AddressIterateResponseMessage msg; |
814 | size_t size; | ||
790 | 815 | ||
791 | /* FIXME: move to a binary format!!! */ | 816 | size = |
792 | GNUNET_asprintf (&addr_buf, "%s: %s", GNUNET_i2s (neighbour), | 817 | sizeof (struct AddressIterateResponseMessage) - |
793 | GST_plugins_a2s ("FIXME", NULL, 0)); | 818 | sizeof (struct GNUNET_MessageHeader); |
794 | transmit_address_to_client (tc, addr_buf); | 819 | memcpy (&msg.peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
795 | GNUNET_free (addr_buf); | 820 | msg.addrlen = ntohs (0); |
821 | msg.pluginlen = ntohs (0); | ||
822 | |||
823 | transmit_binary_to_client (tc, &msg, size); | ||
796 | } | 824 | } |
797 | 825 | ||
798 | 826 | ||