aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_clients.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
commita983a0267109b1b6a8e16e476e2f2956a8771b94 (patch)
tree79bcae73cdb7b87b4f55d4396e79baea76ef53a6 /src/transport/gnunet-service-transport_clients.c
parenta3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff)
downloadgnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.tar.gz
gnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.zip
refactoring how we handle peer addresses in peerinfo/ats/transport/hello subsystems -- use a struct instead of 3--4 arguments
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r--src/transport/gnunet-service-transport_clients.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index ebab72db6..aee592d29 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -325,16 +325,14 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
325 * @param peer identity of the neighbour 325 * @param peer identity of the neighbour
326 * @param ats performance data 326 * @param ats performance data
327 * @param ats_count number of entries in ats (excluding 0-termination) 327 * @param ats_count number of entries in ats (excluding 0-termination)
328 * @param transport plugin 328 * @param address the address
329 * @param addr address
330 * @param addrlen address length
331 */ 329 */
332static void 330static void
333notify_client_about_neighbour (void *cls, 331notify_client_about_neighbour (void *cls,
334 const struct GNUNET_PeerIdentity *peer, 332 const struct GNUNET_PeerIdentity *peer,
335 const struct GNUNET_ATS_Information *ats, 333 const struct GNUNET_ATS_Information *ats,
336 uint32_t ats_count, const char *transport, 334 uint32_t ats_count,
337 const void *addr, size_t addrlen) 335 const struct GNUNET_HELLO_Address *address)
338{ 336{
339 struct TransportClient *tc = cls; 337 struct TransportClient *tc = cls;
340 struct ConnectInfoMessage *cim; 338 struct ConnectInfoMessage *cim;
@@ -719,33 +717,28 @@ clients_handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client,
719 * 717 *
720 * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending) 718 * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending)
721 * @param public_key public key for the peer, never NULL 719 * @param public_key public key for the peer, never NULL
722 * @param target peer this change is about, never NULL
723 * @param valid_until until what time do we consider the address valid? 720 * @param valid_until until what time do we consider the address valid?
724 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) 721 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
725 * is ZERO if the address is considered valid (no validation needed) 722 * is ZERO if the address is considered valid (no validation needed)
726 * is a time in the future if we're currently denying re-validation 723 * is a time in the future if we're currently denying re-validation
727 * @param plugin_name name of the plugin 724 * @param address address to transmit
728 * @param plugin_address binary address
729 * @param plugin_address_len length of address
730 */ 725 */
731static void 726static void
732send_address_to_client (void *cls, 727send_address_to_client (void *cls,
733 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 728 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
734 *public_key, const struct GNUNET_PeerIdentity *target, 729 *public_key,
735 struct GNUNET_TIME_Absolute valid_until, 730 struct GNUNET_TIME_Absolute valid_until,
736 struct GNUNET_TIME_Absolute validation_block, 731 struct GNUNET_TIME_Absolute validation_block,
737 const char *plugin_name, const void *plugin_address, 732 const struct GNUNET_HELLO_Address *address)
738 size_t plugin_address_len)
739{ 733{
740 struct GNUNET_SERVER_TransmitContext *tc = cls; 734 struct GNUNET_SERVER_TransmitContext *tc = cls;
741 char *addr_buf; 735 char *addr_buf;
742 736
743 /* FIXME: move to a binary format!!! */ 737 /* FIXME: move to a binary format!!! */
744 GNUNET_asprintf (&addr_buf, "%s --- %s, %s", 738 GNUNET_asprintf (&addr_buf, "%s --- %s, %s",
745 GST_plugins_a2s (plugin_name, plugin_address, 739 GST_plugins_a2s (address),
746 plugin_address_len),
747 (GNUNET_YES == 740 (GNUNET_YES ==
748 GST_neighbours_test_connected (target)) ? "CONNECTED" : 741 GST_neighbours_test_connected (&address->peer)) ? "CONNECTED" :
749 "DISCONNECTED", 742 "DISCONNECTED",
750 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value > 743 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value >
751 0) ? "VALIDATED" : "UNVALIDATED"); 744 0) ? "VALIDATED" : "UNVALIDATED");
@@ -789,27 +782,26 @@ clients_handle_peer_address_lookup (void *cls,
789 * @param neighbour identity of the neighbour 782 * @param neighbour identity of the neighbour
790 * @param ats performance data 783 * @param ats performance data
791 * @param ats_count number of entries in ats (excluding 0-termination) 784 * @param ats_count number of entries in ats (excluding 0-termination)
792 * @param transport plugin 785 * @param address the address
793 * @param addr address
794 * @param addrlen address length
795 */ 786 */
796static void 787static void
797output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, 788output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer,
798 const struct GNUNET_ATS_Information *ats, uint32_t ats_count, 789 const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
799 const char *transport, const void *addr, size_t addrlen) 790 const struct GNUNET_HELLO_Address *address)
800{ 791{
801 struct GNUNET_SERVER_TransmitContext *tc = cls; 792 struct GNUNET_SERVER_TransmitContext *tc = cls;
802 struct AddressIterateResponseMessage *msg; 793 struct AddressIterateResponseMessage *msg;
803 size_t size; 794 size_t size;
795 size_t slen;
804 796
805 size = 797 slen = strlen (address->transport_name) + 1;
806 (sizeof (struct AddressIterateResponseMessage) + strlen (transport) + 1); 798 size = (sizeof (struct AddressIterateResponseMessage) + slen);
807 msg = GNUNET_malloc (size); 799 msg = GNUNET_malloc (size);
808 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); 800 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
809 memcpy (&msg[0], transport, strlen (transport) + 1); 801 memcpy (&msg[0], address->transport_name, slen);
810 msg->addrlen = ntohs (addrlen); 802 msg->addrlen = ntohs (address->address_length);
811 msg->pluginlen = ntohs (strlen (transport) + 1); 803 msg->pluginlen = ntohs (slen);
812 804 // FIXME: what about 'address->address'!?
813 transmit_binary_to_client (tc, msg, size); 805 transmit_binary_to_client (tc, msg, size);
814 GNUNET_free (msg); 806 GNUNET_free (msg);
815} 807}