*/
struct GNUNET_TESTING_Daemon *d2;
+ /**
+ * Handler for the request to core to connect to this peer.
+ */
+ struct GNUNET_CORE_PeerRequestHandle *connect_request_handle;
+
/**
* Transport handle to the second daemon.
*/
GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->hello_send_task);
ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
}
+
+ if (ctx->connect_request_handle != NULL)
+ {
+ GNUNET_CORE_peer_request_connect_cancel (ctx->connect_request_handle);
+ ctx->connect_request_handle = NULL;
+ }
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
{
if (ctx->d2th != NULL)
ctx->d2th = NULL;
if (ctx->d1core != NULL)
GNUNET_CORE_disconnect (ctx->d1core);
-
+#if CONNECT_CORE2
+ if (ctx->d2core != NULL)
+ GNUNET_CORE_disconnect (ctx->d2core);
+ ctx->d2core = NULL;
+#endif
ctx->d1core = NULL;
+
GNUNET_free (ctx);
return;
}
GNUNET_CORE_disconnect(ctx->d1core);
ctx->d1core = NULL;
}
+#if CONNECT_CORE2
+ if (ctx->d2core != NULL)
+ {
+ GNUNET_CORE_disconnect(ctx->d2core);
+ ctx->d2core = NULL;
+ }
+#endif
if (ctx->d2th != NULL)
{
}
+#if CONNECT_CORE2
+/**
+ * Success, connection is up. Signal client our success.
+ *
+ * @param cls our "struct ConnectContext"
+ * @param peer identity of the peer that has connected
+ * @param latency the round trip latency of the connection to this peer
+ * @param distance distance the transport level distance to this peer
+ *
+ */
+static void
+connect_notify_core2 (void *cls, const struct GNUNET_PeerIdentity * peer, struct GNUNET_TIME_Relative latency,
+ uint32_t distance)
+{
+ struct ConnectContext *ctx = cls;
+
+ if (memcmp(&ctx->d2->id, peer, sizeof(struct GNUNET_PeerIdentity)) == 0)
+ {
+ ctx->connected = GNUNET_YES;
+ ctx->distance = distance;
+ GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task);
+ ctx->timeout_task = GNUNET_SCHEDULER_add_now (ctx->d1->sched,
+ ¬ify_connect_result,
+ ctx);
+ }
+
+}
+#endif
+
+/**
+ * Task called once a core connect request has been transmitted.
+ *
+ * @param cls struct ConnectContext
+ * @param tc context information (why was this task triggered now)
+ */
+void core_connect_request_cont (void *cls,
+ const struct
+ GNUNET_SCHEDULER_TaskContext * tc)
+{
+ struct ConnectContext *ctx = cls;
+
+ if (tc->reason == GNUNET_SCHEDULER_REASON_PREREQ_DONE)
+ ctx->connect_request_handle = NULL;
+ return;
+}
+
static void
send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
hello = GNUNET_HELLO_get_header(ctx->d1->hello);
GNUNET_assert(hello != NULL);
GNUNET_TRANSPORT_offer_hello (ctx->d2th, hello);
+
+ ctx->connect_request_handle = GNUNET_CORE_peer_request_connect (ctx->d1->sched,
+ ctx->d2->cfg,
+ GNUNET_TIME_relative_get_forever(),
+ &ctx->d1->id,
+ &core_connect_request_cont,
+ ctx);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending connect request to core for peer %s\n", GNUNET_i2s(&ctx->d1->id));
ctx->timeout_hello = GNUNET_TIME_relative_add(ctx->timeout_hello,
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,
500));
return;
}
+#if CONNECT_CORE2
+ ctx->d2core = GNUNET_CORE_connect (d2->sched,
+ d2->cfg,
+ timeout,
+ ctx,
+ NULL,
+ NULL, NULL, NULL,
+ NULL, GNUNET_NO,
+ NULL, GNUNET_NO, no_handlers);
+ if (ctx->d2core == NULL)
+ {
+ GNUNET_free (ctx);
+ if (NULL != cb)
+ cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2,
+ _("Failed to connect to core service of second peer!\n"));
+ return;
+ }
+#endif
+
#if DEBUG_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asked to connect peer %s to peer %s\n",
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)