summaryrefslogtreecommitdiff
path: root/src/transport/transport_api_address_to_string.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-29 20:03:12 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-29 20:03:12 +0000
commit75bbeaffe2a1467b6f9f4d80bc4d87ed0d9f14a8 (patch)
tree63885d0e8e55d47ecae25cef37181597115c8980 /src/transport/transport_api_address_to_string.c
parent56c32ea37a52b239494a7f91933e60eb7caf30f3 (diff)
-cleaning up message format and code related to recent transport address stringification code
Diffstat (limited to 'src/transport/transport_api_address_to_string.c')
-rw-r--r--src/transport/transport_api_address_to_string.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c
index 87ee9ad83..5c44c288b 100644
--- a/src/transport/transport_api_address_to_string.c
+++ b/src/transport/transport_api_address_to_string.c
@@ -125,13 +125,16 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
{
size_t len;
size_t alen;
+ size_t slen;
struct AddressLookupMessage *msg;
struct GNUNET_TRANSPORT_AddressToStringContext *alc;
struct GNUNET_CLIENT_Connection *client;
char *addrbuf;
GNUNET_assert (address != NULL);
- len = sizeof (struct AddressLookupMessage) + GNUNET_HELLO_address_get_size (address);
+ alen = address->address_length;
+ slen = strlen (address->transport_name) + 1;
+ len = sizeof (struct AddressLookupMessage) + alen + slen;
if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
@@ -141,19 +144,19 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
client = GNUNET_CLIENT_connect ("transport", cfg);
if (client == NULL)
return NULL;
+#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GNUNET_TRANSPORT_address_to_string\n");
-
- alen = address->address_length;
+#endif
msg = GNUNET_malloc (len);
msg->header.size = htons (len);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING);
- msg->numeric_only = htonl (numeric);
+ msg->numeric_only = htons ((int16_t) numeric);
+ msg->addrlen = htons ((uint16_t) alen);
msg->timeout = GNUNET_TIME_relative_hton (timeout);
- msg->addrlen = htonl (alen);
addrbuf = (char *) &msg[1];
memcpy (addrbuf, address->address, alen);
- strcpy (&addrbuf[alen], address->transport_name);
+ memcpy (&addrbuf[alen], address->transport_name, slen);
alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_AddressToStringContext));
alc->cb = aluc;