GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
#include "gnunet_nat_lib.h"
/* Time to wait before stopping NAT, in seconds */
-#define TIMEOUT 30
+#define TIMEOUT 60
struct addr_cls
{
const struct sockaddr *addr;
socklen_t addrlen;
};
-//typedef addr_cls addr_cls;
static void
addr_callback (void *cls, int add_remove,
static void
stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_NAT_Handle *nat = cls;
+ struct GNUNET_NAT_Handle *nat = cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n");
GNUNET_NAT_unregister (nat);
static int
process_if (void *cls,
const char *name,
- int isDefault,
- const struct sockaddr *addr,
- socklen_t addrlen)
+ int isDefault, const struct sockaddr *addr, socklen_t addrlen)
{
struct addr_cls *data = cls;
data->addrlen = addrlen;
}
+ if (strcmp (name, "eth1") == 0 && addr->sa_family == AF_INET)
+ return GNUNET_SYSERR;
+
+ return GNUNET_OK;
+
+
if (isDefault && addr)
return GNUNET_SYSERR;
else
char *const *args,
const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- GNUNET_NAT_Handle *nat;
+ struct GNUNET_NAT_Handle *nat;
struct addr_cls data;
struct sockaddr *addr;
GNUNET_OS_network_interfaces_list (process_if, &data);
if (!data.addr)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find a valid interface address!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not find a valid interface address!\n");
exit (GNUNET_SYSERR);
}
else
((struct sockaddr_in6 *) addr)->sin6_port = htons (2086);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting NAT redirection from address %s...\n", GNUNET_a2s (addr, data.addrlen));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Requesting NAT redirection from address %s...\n",
+ GNUNET_a2s (addr, data.addrlen));
nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL);
GNUNET_free (addr);
- GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, TIMEOUT),
- stop, nat);
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, TIMEOUT), stop,
+ nat);
}
int
-main (int argc, const char *argv[])
+main (int argc, char *const argv[])
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END