aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_clients.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-11 09:27:07 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-11 09:27:07 +0000
commit4ac8eff7856d655c7a311becdbb7abe3c7551961 (patch)
tree90e426227d569003d985cf21176658d7b37c1b9b /src/transport/gnunet-service-transport_clients.c
parent30b7ff09b7fe180ec262afe7370d0442340182f3 (diff)
downloadgnunet-4ac8eff7856d655c7a311becdbb7abe3c7551961.tar.gz
gnunet-4ac8eff7856d655c7a311becdbb7abe3c7551961.zip
-fix handling
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r--src/transport/gnunet-service-transport_clients.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index a4812e260..fc3abdd1a 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors) 3 (C) 2010-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -268,7 +268,7 @@ setup_client (struct GNUNET_SERVER_Client *client)
268 */ 268 */
269static struct MonitoringClient * 269static struct MonitoringClient *
270lookup_monitoring_client (struct MonitoringClient *head, 270lookup_monitoring_client (struct MonitoringClient *head,
271 struct GNUNET_SERVER_Client *client) 271 struct GNUNET_SERVER_Client *client)
272{ 272{
273 struct MonitoringClient *mc; 273 struct MonitoringClient *mc;
274 274
@@ -290,7 +290,7 @@ lookup_monitoring_client (struct MonitoringClient *head,
290 */ 290 */
291static struct MonitoringClient * 291static struct MonitoringClient *
292setup_peer_monitoring_client (struct GNUNET_SERVER_Client *client, 292setup_peer_monitoring_client (struct GNUNET_SERVER_Client *client,
293 struct GNUNET_PeerIdentity *peer) 293 struct GNUNET_PeerIdentity *peer)
294{ 294{
295 struct MonitoringClient *mc; 295 struct MonitoringClient *mc;
296 static struct GNUNET_PeerIdentity all_zeros; 296 static struct GNUNET_PeerIdentity all_zeros;
@@ -312,6 +312,7 @@ setup_peer_monitoring_client (struct GNUNET_SERVER_Client *client,
312 return mc; 312 return mc;
313} 313}
314 314
315
315/** 316/**
316 * Setup a new monitoring client using the given server client handle and 317 * Setup a new monitoring client using the given server client handle and
317 * the peer identity. 318 * the peer identity.
@@ -323,7 +324,7 @@ setup_peer_monitoring_client (struct GNUNET_SERVER_Client *client,
323 */ 324 */
324static struct MonitoringClient * 325static struct MonitoringClient *
325setup_val_monitoring_client (struct GNUNET_SERVER_Client *client, 326setup_val_monitoring_client (struct GNUNET_SERVER_Client *client,
326 struct GNUNET_PeerIdentity *peer) 327 struct GNUNET_PeerIdentity *peer)
327{ 328{
328 struct MonitoringClient *mc; 329 struct MonitoringClient *mc;
329 static struct GNUNET_PeerIdentity all_zeros; 330 static struct GNUNET_PeerIdentity all_zeros;
@@ -357,7 +358,9 @@ setup_val_monitoring_client (struct GNUNET_SERVER_Client *client,
357 * @return number of bytes written to @a buf 358 * @return number of bytes written to @a buf
358 */ 359 */
359static size_t 360static size_t
360transmit_to_client_callback (void *cls, size_t size, void *buf) 361transmit_to_client_callback (void *cls,
362 size_t size,
363 void *buf)
361{ 364{
362 struct TransportClient *tc = cls; 365 struct TransportClient *tc = cls;
363 struct ClientMessageQueueEntry *q; 366 struct ClientMessageQueueEntry *q;
@@ -465,7 +468,8 @@ unicast (struct TransportClient *tc,
465 * @param client identification of the client 468 * @param client identification of the client
466 */ 469 */
467static void 470static void
468client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) 471client_disconnect_notification (void *cls,
472 struct GNUNET_SERVER_Client *client)
469{ 473{
470 struct TransportClient *tc; 474 struct TransportClient *tc;
471 struct MonitoringClient *mc; 475 struct MonitoringClient *mc;
@@ -526,12 +530,12 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
526 */ 530 */
527static void 531static void
528notify_client_about_neighbour (void *cls, 532notify_client_about_neighbour (void *cls,
529 const struct GNUNET_PeerIdentity *peer, 533 const struct GNUNET_PeerIdentity *peer,
530 const struct GNUNET_HELLO_Address *address, 534 const struct GNUNET_HELLO_Address *address,
531 enum GNUNET_TRANSPORT_PeerState state, 535 enum GNUNET_TRANSPORT_PeerState state,
532 struct GNUNET_TIME_Absolute state_timeout, 536 struct GNUNET_TIME_Absolute state_timeout,
533 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 537 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
534 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) 538 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
535{ 539{
536 struct TransportClient *tc = cls; 540 struct TransportClient *tc = cls;
537 struct ConnectInfoMessage *cim; 541 struct ConnectInfoMessage *cim;
@@ -562,7 +566,8 @@ notify_client_about_neighbour (void *cls,
562 * @param message the start message that was sent 566 * @param message the start message that was sent
563 */ 567 */
564static void 568static void
565clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client, 569clients_handle_start (void *cls,
570 struct GNUNET_SERVER_Client *client,
566 const struct GNUNET_MessageHeader *message) 571 const struct GNUNET_MessageHeader *message)
567{ 572{
568 const struct StartMessage *start; 573 const struct StartMessage *start;
@@ -788,7 +793,8 @@ try_connect_if_allowed (void *cls,
788 * @param message the actual message 793 * @param message the actual message
789 */ 794 */
790static void 795static void
791clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, 796clients_handle_request_connect (void *cls,
797 struct GNUNET_SERVER_Client *client,
792 const struct GNUNET_MessageHeader *message) 798 const struct GNUNET_MessageHeader *message)
793{ 799{
794 const struct TransportRequestConnectMessage *trcm = 800 const struct TransportRequestConnectMessage *trcm =
@@ -897,6 +903,7 @@ transmit_address_to_client (void *cls,
897 a2s_tail, 903 a2s_tail,
898 actx); 904 actx);
899 GNUNET_free (actx); 905 GNUNET_free (actx);
906 return;
900 } 907 }
901 if (GNUNET_SYSERR == res) 908 if (GNUNET_SYSERR == res)
902 { 909 {
@@ -906,26 +913,24 @@ transmit_address_to_client (void *cls,
906 GNUNET_SERVER_transmit_context_append_message (actx->tc, 913 GNUNET_SERVER_transmit_context_append_message (actx->tc,
907 (const struct GNUNET_MessageHeader *) atsm); 914 (const struct GNUNET_MessageHeader *) atsm);
908 GNUNET_free (atsm); 915 GNUNET_free (atsm);
916 return;
909 } 917 }
910 } 918 }
911 else 919 GNUNET_assert (GNUNET_OK == res);
912 { 920 /* succesful conversion, append*/
913 GNUNET_assert (GNUNET_OK == res); 921 slen = strlen (buf) + 1;
914 /* succesful conversion, append*/ 922 len = sizeof (struct AddressToStringResultMessage) + slen;
915 slen = strlen (buf) + 1; 923 atsm = GNUNET_malloc (len);
916 len = sizeof (struct AddressToStringResultMessage) + slen; 924 atsm->header.size = ntohs (len);
917 atsm = GNUNET_malloc (len); 925 atsm->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
918 atsm->header.size = ntohs (len); 926 atsm->res = htonl (GNUNET_YES);
919 atsm->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); 927 atsm->addr_len = htonl (slen);
920 atsm->res = htonl (GNUNET_YES); 928 memcpy (&atsm[1],
921 atsm->addr_len = htonl (slen); 929 buf,
922 memcpy (&atsm[1], 930 slen);
923 buf, 931 GNUNET_SERVER_transmit_context_append_message (actx->tc,
924 slen); 932 (const struct GNUNET_MessageHeader *) atsm);
925 GNUNET_SERVER_transmit_context_append_message (actx->tc, 933 GNUNET_free (atsm);
926 (const struct GNUNET_MessageHeader *) atsm);
927 GNUNET_free (atsm);
928 }
929} 934}
930 935
931 936