struct addr_cls
{
- const struct sockaddr *addr;
+ struct sockaddr *addr;
socklen_t addrlen;
};
{
struct addr_cls *data = cls;
- if (addr)
+ if (addr && addrlen > 0)
{
- data->addr = addr;
+ if (data->addr)
+ GNUNET_free (data->addr);
+ data->addr = memcpy (GNUNET_malloc (addrlen), addr, addrlen);
data->addrlen = addrlen;
+ if (isDefault)
+ return GNUNET_SYSERR;
}
-
- if (strcmp (name, "eth1") == 0 && addr->sa_family == AF_INET)
- return GNUNET_SYSERR;
-
return GNUNET_OK;
-
-
- if (isDefault && addr)
- return GNUNET_SYSERR;
- else
- return GNUNET_OK;
}
static void
run (void *cls,
- struct GNUNET_SCHEDULER_Handle *sched,
char *const *args,
const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
{
"Requesting NAT redirection from address %s...\n",
GNUNET_a2s (addr, data.addrlen));
- nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL);
+ nat = GNUNET_NAT_register (addr, data.addrlen, addr_callback, NULL);
GNUNET_free (addr);
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_relative_multiply
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, TIMEOUT), stop,
nat);
}
GNUNET_GETOPT_OPTION_END
};
- GNUNET_log_setup ("test-nat", "DEBUG", NULL);
+ char *const argv_prog[] = {
+ "test-nat",
+ "-c",
+ "test-nat.conf",
+ "-L",
+#if VERBOSE
+ "DEBUG",
+#else
+ "WARNING",
+#endif
+ NULL
+ };
+
+ GNUNET_log_setup ("test-nat",
+#if VERBOSE
+ "DEBUG",
+#else
+ "WARNING",
+#endif
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Testing NAT library, timeout set to %d seconds\n", TIMEOUT);
- GNUNET_PROGRAM_run (argc, argv, "test-nat", "nohelp", options, &run, NULL);
+ GNUNET_PROGRAM_run (5, argv_prog, "test-nat", "nohelp", options, &run, NULL);
return 0;
}