diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-29 18:04:01 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-29 18:04:01 +0000 |
commit | 56c32ea37a52b239494a7f91933e60eb7caf30f3 (patch) | |
tree | 5c8c8ef6b577da4931ec3e546b2fb60ed0e8f029 /src/transport/gnunet-service-transport_clients.c | |
parent | 5ca85864950a1fe92613f5ed3a69cd08d248423e (diff) | |
download | gnunet-56c32ea37a52b239494a7f91933e60eb7caf30f3.tar.gz gnunet-56c32ea37a52b239494a7f91933e60eb7caf30f3.zip |
- finale commit for the api change
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 7c50218e0..d787c7aab 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -612,7 +612,6 @@ static void | |||
612 | transmit_address_to_client (void *cls, const char *buf) | 612 | transmit_address_to_client (void *cls, const char *buf) |
613 | { | 613 | { |
614 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 614 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
615 | |||
616 | if (NULL == buf) | 615 | if (NULL == buf) |
617 | { | 616 | { |
618 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 617 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, |
@@ -712,6 +711,9 @@ clients_handle_address_to_string (void *cls, struct GNUNET_SERVER_Client *client | |||
712 | tc); | 711 | tc); |
713 | } | 712 | } |
714 | 713 | ||
714 | #if 0 | ||
715 | |||
716 | THIS FUNCTIONALITY IS NOT USED ANYWHERE! | ||
715 | 717 | ||
716 | /** | 718 | /** |
717 | * Send an address to the client. | 719 | * Send an address to the client. |
@@ -749,16 +751,15 @@ send_address_to_client (void *cls, | |||
749 | 751 | ||
750 | 752 | ||
751 | /** | 753 | /** |
752 | * Client asked to obtain information about a peer's addresses. | 754 | * Client asked to obtain information about all addresses of a peer. |
753 | * Process the request. | 755 | * Process the request. |
754 | * FIXME: use better name! | ||
755 | * | 756 | * |
756 | * @param cls unused | 757 | * @param cls unused |
757 | * @param client the client | 758 | * @param client the client |
758 | * @param message the peer address information request | 759 | * @param message the peer address information request |
759 | */ | 760 | */ |
760 | static void | 761 | static void |
761 | clients_handle_peer_address_lookup (void *cls, | 762 | clients_handle_peer_address_iterate (void *cls, |
762 | struct GNUNET_SERVER_Client *client, | 763 | struct GNUNET_SERVER_Client *client, |
763 | const struct GNUNET_MessageHeader *message) | 764 | const struct GNUNET_MessageHeader *message) |
764 | { | 765 | { |
@@ -768,13 +769,15 @@ clients_handle_peer_address_lookup (void *cls, | |||
768 | peer_address_lookup = (const struct PeerAddressLookupMessage *) message; | 769 | peer_address_lookup = (const struct PeerAddressLookupMessage *) message; |
769 | GNUNET_break (ntohl (peer_address_lookup->reserved) == 0); | 770 | GNUNET_break (ntohl (peer_address_lookup->reserved) == 0); |
770 | tc = GNUNET_SERVER_transmit_context_create (client); | 771 | tc = GNUNET_SERVER_transmit_context_create (client); |
772 | |||
771 | GST_validation_get_addresses (&peer_address_lookup->peer, | 773 | GST_validation_get_addresses (&peer_address_lookup->peer, |
772 | &send_address_to_client, tc); | 774 | &send_address_to_client, tc); |
775 | |||
773 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 776 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, |
774 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); | 777 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); |
775 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | 778 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); |
776 | } | 779 | } |
777 | 780 | #endif | |
778 | 781 | ||
779 | /** | 782 | /** |
780 | * Output the active address of connected neighbours to the given client. | 783 | * Output the active address of connected neighbours to the given client. |
@@ -811,15 +814,14 @@ output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
811 | memcpy(&addr[alen], address->transport_name, tlen); | 814 | memcpy(&addr[alen], address->transport_name, tlen); |
812 | 815 | ||
813 | transmit_binary_to_client (tc, msg, size); | 816 | transmit_binary_to_client (tc, msg, size); |
814 | |||
815 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "output_addresses: peer `%s' transport %s address %s %s\n",GNUNET_i2s(&msg->peer), &addr[alen], GNUNET_a2s((struct sockaddr *) addr, alen), GNUNET_a2s((struct sockaddr *) address->address, address->address_length)); | ||
816 | GNUNET_free (msg); | 817 | GNUNET_free (msg); |
817 | } | 818 | } |
818 | 819 | ||
819 | 820 | ||
820 | /** | 821 | /** |
821 | * Client asked to obtain information about all actively used addresses. | 822 | * Client asked to obtain information about all actively used addresses |
822 | * Process the request. FIXME: use better name! | 823 | * of connected peers |
824 | * Process the request. | ||
823 | * | 825 | * |
824 | * @param cls unused | 826 | * @param cls unused |
825 | * @param client the client | 827 | * @param client the client |
@@ -830,11 +832,41 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, | |||
830 | const struct GNUNET_MessageHeader *message) | 832 | const struct GNUNET_MessageHeader *message) |
831 | { | 833 | { |
832 | struct GNUNET_SERVER_TransmitContext *tc; | 834 | struct GNUNET_SERVER_TransmitContext *tc; |
835 | struct AddressIterateMessage * msg; | ||
836 | struct GNUNET_PeerIdentity dummy; | ||
837 | struct GNUNET_HELLO_Address * address; | ||
838 | |||
833 | 839 | ||
834 | GNUNET_SERVER_disable_receive_done_warning (client); | 840 | GNUNET_SERVER_disable_receive_done_warning (client); |
835 | tc = GNUNET_SERVER_transmit_context_create (client); | 841 | tc = GNUNET_SERVER_transmit_context_create (client); |
836 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "clients_handle_address_iterate: \n"); | 842 | |
837 | GST_neighbours_iterate (&output_addresses, tc); | 843 | if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE) |
844 | { | ||
845 | GNUNET_break_op(0); | ||
846 | return; | ||
847 | } | ||
848 | if (ntohs (message->size) != sizeof (struct AddressIterateMessage)) | ||
849 | { | ||
850 | GNUNET_break_op(0); | ||
851 | return; | ||
852 | } | ||
853 | |||
854 | msg = (struct AddressIterateMessage *) message; | ||
855 | memset (&dummy, 0, sizeof (struct GNUNET_PeerIdentity)); | ||
856 | |||
857 | if (0 == memcmp (&msg->peer, &dummy, sizeof (struct GNUNET_PeerIdentity))) | ||
858 | { | ||
859 | /* iterate over all neighbours */ | ||
860 | GST_neighbours_iterate (&output_addresses, tc); | ||
861 | } | ||
862 | else | ||
863 | { | ||
864 | /* just return one neighbour */ | ||
865 | address = GST_neighbour_get_current_address(&msg->peer); | ||
866 | if (address != NULL) | ||
867 | output_addresses(tc, &msg->peer, NULL, 0, address); | ||
868 | } | ||
869 | |||
838 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 870 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, |
839 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); | 871 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); |
840 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | 872 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); |
@@ -859,12 +891,16 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) | |||
859 | {&clients_handle_request_connect, NULL, | 891 | {&clients_handle_request_connect, NULL, |
860 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, | 892 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, |
861 | sizeof (struct TransportRequestConnectMessage)}, | 893 | sizeof (struct TransportRequestConnectMessage)}, |
894 | /* converts a binary address to a human readable address */ | ||
862 | {&clients_handle_address_to_string, NULL, | 895 | {&clients_handle_address_to_string, NULL, |
863 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, | 896 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, |
864 | {&clients_handle_peer_address_lookup, NULL, | 897 | #if 0 |
898 | /* Not used at the moment, gets all addresses of a peer */ | ||
899 | {&clients_handle_peer_address_iterate, NULL, | ||
865 | GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP, | 900 | GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP, |
866 | sizeof (struct PeerAddressLookupMessage)}, | 901 | sizeof (struct PeerAddressLookupMessage)}, |
867 | {&clients_handle_address_iterate, NULL, | 902 | #endif |
903 | {&clients_handle_address_iterate, NULL, | ||
868 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE, | 904 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE, |
869 | sizeof (struct AddressIterateMessage)}, | 905 | sizeof (struct AddressIterateMessage)}, |
870 | {&GST_blacklist_handle_init, NULL, | 906 | {&GST_blacklist_handle_init, NULL, |