copy const address
authort3sserakt <t3ss@posteo.de>
Tue, 5 May 2020 10:08:32 +0000 (12:08 +0200)
committert3sserakt <t3ss@posteo.de>
Tue, 5 May 2020 10:08:32 +0000 (12:08 +0200)
src/transport/gnunet-communicator-tcp.c

index 496ebc950256bb9423ca659485806245e0b9b03f..7c19a31f6935e8e70c66d4da7c7180b1386e57a8 100644 (file)
@@ -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);
 }