diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index d9a750e29..171644123 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -863,17 +863,39 @@ static void | |||
863 | transmit_address_to_client (void *cls, const char *buf) | 863 | transmit_address_to_client (void *cls, const char *buf) |
864 | { | 864 | { |
865 | struct AddressToStringContext *actx = cls; | 865 | struct AddressToStringContext *actx = cls; |
866 | struct AddressToStringResultMessage *atsm; | ||
867 | size_t len; | ||
868 | |||
869 | if (NULL != buf) | ||
870 | { | ||
871 | len = sizeof (struct AddressToStringResultMessage) + strlen (buf) + 1; | ||
872 | atsm = GNUNET_malloc (len); | ||
873 | atsm->header.size = ntohs (len); | ||
874 | atsm->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | ||
875 | atsm->res = htonl (GNUNET_YES); | ||
876 | atsm->addr_len = htonl (strlen (buf) + 1); | ||
877 | memcpy (&atsm[1], buf, strlen (buf) + 1); | ||
878 | } | ||
879 | else | ||
880 | { | ||
881 | len = sizeof (struct AddressToStringResultMessage); | ||
882 | atsm = GNUNET_malloc (len); | ||
883 | atsm->header.size = ntohs (len); | ||
884 | atsm->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | ||
885 | atsm->res = htonl (GNUNET_NO); | ||
886 | atsm->addr_len = htonl (0); | ||
887 | } | ||
888 | |||
866 | if (NULL == buf) | 889 | if (NULL == buf) |
867 | { | 890 | { |
868 | GNUNET_SERVER_transmit_context_append_data (actx->tc, NULL, 0, | 891 | /* Address could not be converted */ |
869 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 892 | GNUNET_SERVER_transmit_context_append_message (actx->tc, (const struct GNUNET_MessageHeader *)atsm); |
870 | GNUNET_SERVER_transmit_context_run (actx->tc, GNUNET_TIME_UNIT_FOREVER_REL); | 893 | GNUNET_SERVER_transmit_context_run (actx->tc, GNUNET_TIME_UNIT_FOREVER_REL); |
871 | GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx); | 894 | GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx); |
872 | GNUNET_free (actx); | 895 | GNUNET_free (actx); |
873 | return; | 896 | return; |
874 | } | 897 | } |
875 | GNUNET_SERVER_transmit_context_append_data (actx->tc, buf, strlen (buf) + 1, | 898 | GNUNET_SERVER_transmit_context_append_message (actx->tc, (const struct GNUNET_MessageHeader *) atsm); |
876 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | ||
877 | } | 899 | } |
878 | 900 | ||
879 | 901 | ||
@@ -897,6 +919,7 @@ clients_handle_address_to_string (void *cls, | |||
897 | uint16_t size; | 919 | uint16_t size; |
898 | struct GNUNET_SERVER_TransmitContext *tc; | 920 | struct GNUNET_SERVER_TransmitContext *tc; |
899 | struct AddressToStringContext *actx; | 921 | struct AddressToStringContext *actx; |
922 | struct AddressToStringResultMessage atsm; | ||
900 | struct GNUNET_TIME_Relative rtimeout; | 923 | struct GNUNET_TIME_Relative rtimeout; |
901 | int32_t numeric; | 924 | int32_t numeric; |
902 | 925 | ||
@@ -929,8 +952,12 @@ clients_handle_address_to_string (void *cls, | |||
929 | papi = GST_plugins_printer_find (plugin_name); | 952 | papi = GST_plugins_printer_find (plugin_name); |
930 | if (NULL == papi) | 953 | if (NULL == papi) |
931 | { | 954 | { |
932 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | 955 | atsm.header.size = ntohs (sizeof (struct AddressToStringResultMessage)); |
933 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 956 | atsm.header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); |
957 | atsm.res = htonl (GNUNET_NO); | ||
958 | atsm.addr_len = htonl (0); | ||
959 | GNUNET_SERVER_transmit_context_append_message (tc, | ||
960 | (const struct GNUNET_MessageHeader *) &atsm); | ||
934 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); | 961 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); |
935 | return; | 962 | return; |
936 | } | 963 | } |