struct UpdateContext
{
struct GNUNET_CONFIGURATION_Handle *ret;
+ const struct GNUNET_CONFIGURATION_Handle *orig;
const char *hostname;
unsigned int nport;
unsigned int upnum;
unsigned int ival;
char cval[12];
char uval[128];
+ char *single_variable;
if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
{
- if (ival != 0)
+ GNUNET_asprintf(&single_variable, "single_%s_per_host", section);
+ if ((ival != 0) && (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno(ctx->orig, "testing", single_variable)))
{
GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++);
value = cval;
}
+
+ GNUNET_free(single_variable);
}
if (0 == strcmp (option, "UNIXPATH"))
{
- GNUNET_snprintf (uval,
- sizeof (uval),
- "/tmp/test-service-%s-%u",
- section,
- ctx->upnum++);
- value = uval;
+ GNUNET_asprintf(&single_variable, "single_%s_per_host", section);
+ if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno(ctx->orig, "testing", single_variable))
+ {
+ GNUNET_snprintf (uval,
+ sizeof (uval),
+ "/tmp/test-service-%s-%u",
+ section,
+ ctx->upnum++);
+ value = uval;
+ }
+ GNUNET_free(single_variable);
+
}
if ((0 == strcmp (option, "HOSTNAME")) && (ctx->hostname != NULL))
uc.upnum = *upnum;
uc.ret = GNUNET_CONFIGURATION_create ();
uc.hostname = hostname;
+ uc.orig = cfg;
GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc);
if (uc.nport >= HIGH_PORT)
return NULL;
}
+/*
+ * Get a daemon by peer identity, so callers can
+ * retrieve the daemon without knowing it's offset.
+ *
+ * @param pg the peer group to retrieve the daemon from
+ * @param peer_id the peer identity of the daemon to retrieve
+ *
+ * @return the daemon on success, or NULL if no such peer identity is found
+ */
+struct GNUNET_TESTING_Daemon *
+GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg, struct GNUNET_PeerIdentity *peer_id)
+{
+ unsigned int i;
+
+ for (i = 0; i < pg->total; i ++)
+ {
+ if (0 == memcmp(&pg->peers[i].daemon->id, peer_id, sizeof(struct GNUNET_PeerIdentity)))
+ return pg->peers[i].daemon;
+ }
+
+ return NULL;
+}
+
/**
* Prototype of a function that will be called when a
* particular operation was completed the testing library.