aboutsummaryrefslogtreecommitdiff
path: root/src/nat/gnunet-service-nat_helper.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-12-16 10:53:58 +0100
committerChristian Grothoff <christian@grothoff.org>2016-12-16 10:53:58 +0100
commit8108e41d89bb771fe8bcf887919de3f581f1cc0d (patch)
tree970c382485c663f8c8516b59e34790d33878dbfb /src/nat/gnunet-service-nat_helper.c
parentf88d55e43f3d3a4468c2faa0621044ad17594e5f (diff)
downloadgnunet-8108e41d89bb771fe8bcf887919de3f581f1cc0d.tar.gz
gnunet-8108e41d89bb771fe8bcf887919de3f581f1cc0d.zip
add PORT to NAT configuration, generate nat.conf from nat.conf.in, implement more of new NAT service
Diffstat (limited to 'src/nat/gnunet-service-nat_helper.c')
-rw-r--r--src/nat/gnunet-service-nat_helper.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/nat/gnunet-service-nat_helper.c b/src/nat/gnunet-service-nat_helper.c
index e476da12d..379603ae2 100644
--- a/src/nat/gnunet-service-nat_helper.c
+++ b/src/nat/gnunet-service-nat_helper.c
@@ -319,7 +319,7 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h)
319 GNUNET_SCHEDULER_cancel (h->server_read_task); 319 GNUNET_SCHEDULER_cancel (h->server_read_task);
320 h->server_read_task = NULL; 320 h->server_read_task = NULL;
321 } 321 }
322 if (NULL != h->server_proc) 322 if (NULL != h->server_proc)
323 { 323 {
324 if (0 != GNUNET_OS_process_kill (h->server_proc, 324 if (0 != GNUNET_OS_process_kill (h->server_proc,
325 GNUNET_TERM_SIG)) 325 GNUNET_TERM_SIG))
@@ -349,23 +349,25 @@ GN_stop_gnunet_nat_server_ (struct HelperContext *h)
349 * that peer to connect to us (connection reversal). 349 * that peer to connect to us (connection reversal).
350 * 350 *
351 * @param internal_address out internal address to use 351 * @param internal_address out internal address to use
352 * @param sa the address of the peer (IPv4-only) 352 * @param internal_port port to use
353 * @param remote_v4 the address of the peer (IPv4-only)
353 * @return #GNUNET_SYSERR on error, 354 * @return #GNUNET_SYSERR on error,
354 * #GNUNET_OK otherwise 355 * #GNUNET_OK otherwise
355 */ 356 */
356int 357int
357GN_request_connection_reversal (const char *internal_address, 358GN_request_connection_reversal (const struct in_addr *internal_address,
358 const struct sockaddr_in *sa) 359 uint16_t internal_port,
360 const struct in_addr *remote_v4)
359{ 361{
360 char inet4[INET_ADDRSTRLEN]; 362 char intv4[INET_ADDRSTRLEN];
363 char remv4[INET_ADDRSTRLEN];
361 char port_as_string[6]; 364 char port_as_string[6];
362 struct GNUNET_OS_Process *proc; 365 struct GNUNET_OS_Process *proc;
363 char *binary; 366 char *binary;
364 367
365 GNUNET_assert (sa->sin_family == AF_INET);
366 if (NULL == inet_ntop (AF_INET, 368 if (NULL == inet_ntop (AF_INET,
367 &sa->sin_addr, 369 internal_address,
368 inet4, 370 intv4,
369 INET_ADDRSTRLEN)) 371 INET_ADDRSTRLEN))
370 { 372 {
371 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, 373 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING,
@@ -373,15 +375,25 @@ GN_request_connection_reversal (const char *internal_address,
373 "inet_ntop"); 375 "inet_ntop");
374 return GNUNET_SYSERR; 376 return GNUNET_SYSERR;
375 } 377 }
378 if (NULL == inet_ntop (AF_INET,
379 remote_v4,
380 remv4,
381 INET_ADDRSTRLEN))
382 {
383 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING,
384 "nat",
385 "inet_ntop");
386 return GNUNET_SYSERR;
387 }
376 GNUNET_snprintf (port_as_string, 388 GNUNET_snprintf (port_as_string,
377 sizeof (port_as_string), 389 sizeof (port_as_string),
378 "%d", 390 "%d",
379 ntohs (sa->sin_port)); 391 internal_port);
380 LOG (GNUNET_ERROR_TYPE_DEBUG, 392 LOG (GNUNET_ERROR_TYPE_DEBUG,
381 _("Running gnunet-helper-nat-client %s %s %u\n"), 393 _("Running gnunet-helper-nat-client %s %s %u\n"),
382 internal_address, 394 intv4,
383 inet4, 395 remv4,
384 ntohs (sa->sin_port)); 396 internal_port);
385 binary 397 binary
386 = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client"); 398 = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client");
387 proc 399 proc
@@ -392,8 +404,8 @@ GN_request_connection_reversal (const char *internal_address,
392 NULL, 404 NULL,
393 binary, 405 binary,
394 "gnunet-helper-nat-client", 406 "gnunet-helper-nat-client",
395 internal_address, 407 intv4,
396 inet4, 408 remv4,
397 port_as_string, 409 port_as_string,
398 NULL); 410 NULL);
399 GNUNET_free (binary); 411 GNUNET_free (binary);