From: Matthias Wachs Date: Mon, 2 Apr 2012 13:55:53 +0000 (+0000) Subject: - fix ipv6 address format for tcp pretty printer X-Git-Tag: initial-import-from-subversion-38251~14023 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=36acce256ce3d0a4dd85bb562b82895ed9f4017b;p=oweals%2Fgnunet.git - fix ipv6 address format for tcp pretty printer --- 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;