#include "gnunet_signatures.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
-#include "plugin_transport.h"
+#include "gnunet_transport_plugin.h"
#include "transport.h"
#define DEBUG_TCP GNUNET_NO
/**
* The process id of the server process (if behind NAT)
*/
- pid_t server_pid;
+ struct GNUNET_OS_Process *server_proc;
/**
* List of open TCP sessions.
GNUNET_break (session->client != NULL);
if (session->receive_delay_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (session->plugin->env->sched,
- session->receive_delay_task);
+ GNUNET_SCHEDULER_cancel (session->receive_delay_task);
if (session->client != NULL)
GNUNET_SERVER_receive_done (session->client,
GNUNET_SYSERR);
char inet4[INET_ADDRSTRLEN];
char *address_as_string;
char *port_as_string;
- pid_t pid;
+ struct GNUNET_OS_Process *proc;
const struct sockaddr *sa = (const struct sockaddr *)addr;
#if DEBUG_TCP_NAT
#endif
/* Start the client process */
- pid = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
+ proc = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
GNUNET_free(address_as_string);
GNUNET_free(port_as_string);
- GNUNET_OS_process_wait (pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
}
/* Only do one NAT punch attempt per peer identity */
return -1;
}
- sa = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched,
- af, sb, sbs);
+ sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs);
if (sa == NULL)
{
#if DEBUG_TCP
ppc->asc = asc;
ppc->asc_cls = asc_cls;
ppc->port = port;
- GNUNET_RESOLVER_hostname_get (plugin->env->sched,
- plugin->env->cfg,
+ GNUNET_RESOLVER_hostname_get (plugin->env->cfg,
sb,
sbs,
!numeric, timeout, &append_port, ppc);
GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
else
session->receive_delay_task =
- GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
- delay, &delayed_done, session);
+ GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
}
GNUNET_SERVER_receive_done (client, GNUNET_OK);
else
session->receive_delay_task =
- GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
- delay, &delayed_done, session);
+ GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
}
else
{
plugin->server_read_task =
- GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
return;
}
_("nat-server-read malformed address\n"), &mybuf, port);
plugin->server_read_task =
- GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
return;
}
* We have received an ICMP response, ostensibly from a non-NAT'd peer
* that wants to connect to us! Send a message to establish a connection.
*/
- sock = GNUNET_CONNECTION_create_from_sockaddr (plugin->env->sched, AF_INET, (struct sockaddr *)&in_addr,
+ sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, (struct sockaddr *)&in_addr,
sizeof(in_addr));
if (sock == NULL)
{
plugin->server_read_task =
- GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
return;
}
/*GNUNET_SERVER_connect_socket(plugin->server, sock);*/
plugin->server_read_task =
- GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
}
"Starting gnunet-nat-server process cmd: %s %s\n", "gnunet-nat-server", plugin->internal_address);
#endif
/* Start the server process */
- plugin->server_pid = GNUNET_OS_start_process(NULL, plugin->server_stdout, "gnunet-nat-server", "gnunet-nat-server", plugin->internal_address, NULL);
- if (plugin->server_pid == GNUNET_SYSERR)
+ plugin->server_proc = GNUNET_OS_start_process(NULL, plugin->server_stdout, "gnunet-nat-server", "gnunet-nat-server", plugin->internal_address, NULL);
+ if (plugin->server_proc == NULL)
{
#if DEBUG_TCP_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ);
plugin->server_read_task =
- GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdout_handle, &tcp_plugin_server_read, plugin);
return GNUNET_YES;
}
struct sockaddr_in in_addr;
struct IPv4TcpAddress t4;
- service = GNUNET_SERVICE_start ("transport-tcp", env->sched, env->cfg);
+ service = GNUNET_SERVICE_start ("transport-tcp", env->cfg);
if (service == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
}
- plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched,
- env->cfg,
+ plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->cfg,
AF_UNSPEC,
HOSTNAME_RESOLVE_TIMEOUT,
&process_hostname_ips,
if (plugin->behind_nat == GNUNET_YES)
{
- if (0 != PLIBC_KILL (plugin->server_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (plugin->server_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (plugin->server_pid);
+ GNUNET_OS_process_wait (plugin->server_proc);
+ GNUNET_OS_process_close (plugin->server_proc);
+ plugin->server_proc = NULL;
}
GNUNET_free_non_null(plugin->bind_address);
GNUNET_free (plugin);