int delete_files, int allow_restart);
+
+/**
+ * Create a new configuration using the given configuration
+ * as a template; however, each PORT in the existing cfg
+ * must be renumbered by incrementing "*port". If we run
+ * out of "*port" numbers, return NULL.
+ *
+ * @param cfg template configuration
+ * @param off the current peer offset
+ * @param port port numbers to use, update to reflect
+ * port numbers that were used
+ * @param upnum number to make unix domain socket names unique
+ * @param hostname hostname of the controlling host, to allow control connections from
+ * @param fdnum number used to offset the unix domain socket for grouped processes
+ * (such as statistics or peerinfo, which can be shared among others)
+ *
+ * @return new configuration, NULL on error
+ */
+struct GNUNET_CONFIGURATION_Handle *
+GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
+ uint16_t * port, uint32_t * upnum, const char *hostname,
+ uint32_t * fdnum);
+
/**
* Changes the configuration of a GNUnet daemon.
*
static int
create_unique_cfgs (const char * template, const unsigned int no)
{
+ int fail = GNUNET_NO;
+
+ uint16_t port = 20000;
+ uint32_t upnum = 1;
+ uint32_t fdnum = 1;
+
if (GNUNET_NO == GNUNET_DISK_file_test(template))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template);
return 1;
}
- return 0;
+
+ int cur = 0;
+ char * cur_file;
+ struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create();
+ struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL;
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template);
+ GNUNET_CONFIGURATION_destroy(cfg_tmpl);
+
+ return 1;
+ }
+
+ while (cur < no)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating configuration no. %u \n", cur);
+ GNUNET_asprintf(&cur_file,"%04u-%s",cur, create_cfg_template);
+ cfg_new = GNUNET_TESTING_create_cfg(cfg_tmpl, cur, &port, &upnum, NULL, &fdnum);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Writing configuration no. %u to file `%s' \n", cur, cur_file);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. %u \n", cur);
+ fail = GNUNET_YES;
+ }
+
+
+ GNUNET_free (cur_file);
+ if (fail == GNUNET_YES)
+ break;
+ cur ++;
+ }
+
+ GNUNET_CONFIGURATION_destroy(cfg_tmpl);
+ if (fail == GNUNET_NO)
+ return 0;
+ else
+ return 1;
}
/**
*
* @return new configuration, NULL on error
*/
-static struct GNUNET_CONFIGURATION_Handle *
-make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
+struct GNUNET_CONFIGURATION_Handle *
+GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
uint16_t * port, uint32_t * upnum, const char *hostname,
uint32_t * fdnum)
{
}
else
{
+
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp",
"USE_LOCALADDR", "YES");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp",
"127.0.0.1");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "EXTERNAL_ADDRESS",
"127.0.0.1");
- GNUNET_CONFIGURATION_set_value_string (uc.ret, "disablev6", "BINDTO",
+ GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "disablev6",
"YES");
}
username = pg->hosts[off % hostcnt].username;
sshport = pg->hosts[off % hostcnt].sshport;
pcfg =
- make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum,
+ GNUNET_TESTING_create_cfg (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum,
hostname, &fdnum);
}
else
hostname = NULL;
username = NULL;
sshport = 0;
- pcfg = make_config (cfg, off, &minport, &upnum, hostname, &fdnum);
+ pcfg = GNUNET_TESTING_create_cfg (cfg, off, &minport, &upnum, hostname, &fdnum);
}
if (NULL == pcfg)