From c52cfa11016444f1bc1f33876162e7589f27e4a1 Mon Sep 17 00:00:00 2001 From: t3sserakt Date: Tue, 5 May 2020 12:08:32 +0200 Subject: [PATCH] copy const address --- src/transport/gnunet-communicator-tcp.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 496ebc950..7c19a31f6 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c @@ -2242,7 +2242,7 @@ init_socket (void *cls, GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); GNUNET_free ((struct sockaddr *) addr); return; - } + } if (GNUNET_OK != GNUNET_NETWORK_socket_bind (listen_sock, addr, in_len)) { @@ -2250,7 +2250,7 @@ init_socket (void *cls, GNUNET_NETWORK_socket_close (listen_sock); listen_sock = NULL; return; - } + } if (GNUNET_OK != GNUNET_NETWORK_socket_listen (listen_sock, @@ -2260,7 +2260,8 @@ init_socket (void *cls, "listen"); GNUNET_NETWORK_socket_close (listen_sock); listen_sock = NULL; - } + return; + } /* We might have bound to port 0, allowing the OS to figure it out; thus, get the real IN-address from the socket */ @@ -2328,6 +2329,7 @@ init_socket (void *cls, NULL /* FIXME: support reversal: #5529 */, NULL /* closure */); + if (NULL == nat) { GNUNET_break (0); @@ -2339,6 +2341,7 @@ init_socket (void *cls, //TODO Remove this, if we like to handle more then one address. if (NULL != resolve_request_handle) GNUNET_RESOLVER_request_cancel (resolve_request_handle); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "init_own finished %s\n", GNUNET_a2s (addr, in_len)); @@ -2352,19 +2355,22 @@ init_socket_resolv (void *cls, { struct sockaddr_in *v4; struct sockaddr_in6 *v6; + struct sockaddr *in; if (NULL != addr) { if (AF_INET == addr->sa_family) { v4 = (struct sockaddr_in *) addr; - v4->sin_port = htons ((uint16_t) port_global); + /* v4->sin_port = htons ((uint16_t) port_global);*/ + in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, port_global); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ipv4 \n"); }else if (AF_INET6 == addr->sa_family) { - v6 = (struct sockaddr_in6 *) addr; - v6->sin6_port = htons ((uint16_t) port_global); + v6 = (struct sockaddr_in6 *) addr; + /*v6->sin6_port = htons ((uint16_t) port_global);*/ + in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, port_global); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ipv6 \n"); }else @@ -2380,10 +2386,10 @@ init_socket_resolv (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address is NULL. This might be an error or the resolver finished resolving.\n"); - } + } init_socket (cls, - addr, + in, in_len); } -- 2.25.1