From 36acce256ce3d0a4dd85bb562b82895ed9f4017b Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 2 Apr 2012 13:55:53 +0000 Subject: [PATCH] - fix ipv6 address format for tcp pretty printer --- src/transport/gnunet-service-transport_clients.c | 4 ++++ src/transport/plugin_transport_tcp.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index d6ff55449..227f4f093 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -788,6 +788,10 @@ clients_handle_address_to_string (void *cls, return; } GNUNET_SERVER_disable_receive_done_warning (client); + if ((NULL == address) || (0 == address_len)) + { + GNUNET_break_op (0); + } papi->address_pretty_printer (papi->cls, plugin_name, address, address_len, numeric, rtimeout, &transmit_address_to_client, tc); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 95041d899..2fa96b464 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1369,6 +1369,8 @@ struct PrettyPrinterContext * Port to add after the IP address. */ uint16_t port; + + int ipv6; }; @@ -1390,7 +1392,10 @@ append_port (void *cls, const char *hostname) GNUNET_free (ppc); return; } - GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); + if (GNUNET_YES == ppc->ipv6) + GNUNET_asprintf (&ret, "[%s]:%d", hostname, ppc->port); + else + GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); ppc->asc (ppc->asc_cls, ret); GNUNET_free (ret); } @@ -1452,11 +1457,17 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type, else { /* invalid address */ + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", + "Invalid address to string request: plugin `%s', address length: %u bytes\n"); GNUNET_break_op (0); asc (asc_cls, NULL); return; } ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext)); + if (addrlen == sizeof (struct IPv6TcpAddress)) + ppc->ipv6 = GNUNET_YES; + else + ppc->ipv6 = GNUNET_NO; ppc->asc = asc; ppc->asc_cls = asc_cls; ppc->port = port; -- 2.25.1