diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 8b022ef7e..ebab72db6 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -165,8 +165,7 @@ setup_client (struct GNUNET_SERVER_Client *client) | |||
165 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); | 165 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); |
166 | 166 | ||
167 | #if DEBUG_TRANSPORT | 167 | #if DEBUG_TRANSPORT |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %X connected\n", tc); |
169 | "Client %X connected\n", tc); | ||
170 | #endif | 169 | #endif |
171 | return tc; | 170 | return tc; |
172 | } | 171 | } |
@@ -333,29 +332,26 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) | |||
333 | static void | 332 | static void |
334 | notify_client_about_neighbour (void *cls, | 333 | notify_client_about_neighbour (void *cls, |
335 | const struct GNUNET_PeerIdentity *peer, | 334 | const struct GNUNET_PeerIdentity *peer, |
336 | const struct GNUNET_ATS_Information | 335 | const struct GNUNET_ATS_Information *ats, |
337 | *ats, uint32_t ats_count, | 336 | uint32_t ats_count, const char *transport, |
338 | const char * transport, | 337 | const void *addr, size_t addrlen) |
339 | const void * addr, | ||
340 | size_t addrlen) | ||
341 | { | 338 | { |
342 | struct TransportClient *tc = cls; | 339 | struct TransportClient *tc = cls; |
343 | struct ConnectInfoMessage *cim; | 340 | struct ConnectInfoMessage *cim; |
344 | struct GNUNET_ATS_Information *ap; | 341 | struct GNUNET_ATS_Information *ap; |
345 | size_t size = | 342 | size_t size = |
346 | sizeof (struct ConnectInfoMessage) + | 343 | sizeof (struct ConnectInfoMessage) + |
347 | ats_count * sizeof (struct GNUNET_ATS_Information); | 344 | ats_count * sizeof (struct GNUNET_ATS_Information); |
348 | char buf[size]; | 345 | char buf[size]; |
349 | 346 | ||
350 | GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 347 | GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
351 | cim = (struct ConnectInfoMessage*) buf; | 348 | cim = (struct ConnectInfoMessage *) buf; |
352 | cim->header.size = htons (size); | 349 | cim->header.size = htons (size); |
353 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 350 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
354 | cim->ats_count = htonl (ats_count); | 351 | cim->ats_count = htonl (ats_count); |
355 | cim->id = *peer; | 352 | cim->id = *peer; |
356 | ap = (struct GNUNET_ATS_Information *) &cim[1]; | 353 | ap = (struct GNUNET_ATS_Information *) &cim[1]; |
357 | memcpy (ap, ats, | 354 | memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); |
358 | ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
359 | unicast (tc, &cim->header, GNUNET_NO); | 355 | unicast (tc, &cim->header, GNUNET_NO); |
360 | } | 356 | } |
361 | 357 | ||
@@ -401,10 +397,10 @@ clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
401 | } | 397 | } |
402 | start = (const struct StartMessage *) message; | 398 | start = (const struct StartMessage *) message; |
403 | options = ntohl (start->options); | 399 | options = ntohl (start->options); |
404 | if ((0 != (1 & options) ) && | 400 | if ((0 != (1 & options)) && |
405 | (0 != | 401 | (0 != |
406 | memcmp (&start->self, &GST_my_identity, | 402 | memcmp (&start->self, &GST_my_identity, |
407 | sizeof (struct GNUNET_PeerIdentity)))) | 403 | sizeof (struct GNUNET_PeerIdentity)))) |
408 | { | 404 | { |
409 | /* client thinks this is a different peer, reject */ | 405 | /* client thinks this is a different peer, reject */ |
410 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 406 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -799,26 +795,23 @@ clients_handle_peer_address_lookup (void *cls, | |||
799 | */ | 795 | */ |
800 | static void | 796 | static void |
801 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, | 797 | output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, |
802 | const struct GNUNET_ATS_Information *ats, | 798 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count, |
803 | uint32_t ats_count, | 799 | const char *transport, const void *addr, size_t addrlen) |
804 | const char * transport, | ||
805 | const void * addr, | ||
806 | size_t addrlen) | ||
807 | { | 800 | { |
808 | struct GNUNET_SERVER_TransmitContext *tc = cls; | 801 | struct GNUNET_SERVER_TransmitContext *tc = cls; |
809 | struct AddressIterateResponseMessage * msg; | 802 | struct AddressIterateResponseMessage *msg; |
810 | size_t size; | 803 | size_t size; |
811 | 804 | ||
812 | size = | 805 | size = |
813 | (sizeof (struct AddressIterateResponseMessage) + strlen(transport) + 1); | 806 | (sizeof (struct AddressIterateResponseMessage) + strlen (transport) + 1); |
814 | msg = GNUNET_malloc (size); | 807 | msg = GNUNET_malloc (size); |
815 | memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); | 808 | memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
816 | memcpy (&msg[0], transport, strlen(transport)+1); | 809 | memcpy (&msg[0], transport, strlen (transport) + 1); |
817 | msg->addrlen = ntohs (addrlen); | 810 | msg->addrlen = ntohs (addrlen); |
818 | msg->pluginlen = ntohs (strlen(transport)+1); | 811 | msg->pluginlen = ntohs (strlen (transport) + 1); |
819 | 812 | ||
820 | transmit_binary_to_client (tc, msg, size); | 813 | transmit_binary_to_client (tc, msg, size); |
821 | GNUNET_free(msg); | 814 | GNUNET_free (msg); |
822 | } | 815 | } |
823 | 816 | ||
824 | 817 | ||
@@ -908,9 +901,8 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop) | |||
908 | 901 | ||
909 | for (tc = clients_head; tc != NULL; tc = tc->next) | 902 | for (tc = clients_head; tc != NULL; tc = tc->next) |
910 | { | 903 | { |
911 | if ( (GNUNET_YES == may_drop) && | 904 | if ((GNUNET_YES == may_drop) && (GNUNET_YES != tc->send_payload)) |
912 | (GNUNET_YES != tc->send_payload) ) | 905 | continue; /* skip, this client does not care about payload */ |
913 | continue; /* skip, this client does not care about payload */ | ||
914 | unicast (tc, msg, may_drop); | 906 | unicast (tc, msg, may_drop); |
915 | } | 907 | } |
916 | } | 908 | } |