struct GNUNET_TESTBED_Operation *connect_op;
};
+struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_ATS_TEST_Topology *top;
int c_op;
struct BenchmarkPeer *p;
- top->shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+ top->shutdown_task = NULL;
top->state.benchmarking = GNUNET_NO;
GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
p->peer_id_op = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != p->ats_task)
+ if (NULL != p->ats_task)
GNUNET_SCHEDULER_cancel (p->ats_task);
- p->ats_task = GNUNET_SCHEDULER_NO_TASK;
+ p->ats_task = NULL;
for (c_op = 0; c_op < p->num_partners; c_op++)
{
_("Failed to connect master peer [%u] with slave [%u]\n"),
cop->master->no, cop->slave->no);
GNUNET_break(0);
- if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
+ if (NULL != top->shutdown_task)
GNUNET_SCHEDULER_cancel (top->shutdown_task);
top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
}
_("Could not connect master [%u] and slave [%u]\n"), p->no,
top->sps[c_s].no);
GNUNET_break(0);
- if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
+ if (NULL != top->shutdown_task)
GNUNET_SCHEDULER_cancel (top->shutdown_task);
top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
return;
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
GNUNET_break(0);
- if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
+ if (NULL != top->shutdown_task)
GNUNET_SCHEDULER_cancel (top->shutdown_task);
top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
return;
}
}
+
static void
ats_performance_info_cb (void *cls,
- const struct GNUNET_HELLO_Address *address,
- int address_active,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_HELLO_Address *address,
+ int address_active,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count)
{
struct BenchmarkPeer *me = cls;
struct BenchmarkPartner *p;
}
}
if (GNUNET_YES == log)
- top->ats_perf_cb (cls, address, address_active, bandwidth_out, bandwidth_in,
- ats, ats_count);
+ top->ats_perf_cb (cls, address,
+ address_active,
+ bandwidth_out,
+ bandwidth_in,
+ ats, ats_count);
GNUNET_free(peer_id);
}
{
struct BenchmarkPeer *me = cls;
- me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, ats_performance_info_cb, me);
+ me->ats_perf_handle = GNUNET_ATS_performance_init (cfg,
+ &ats_performance_info_cb,
+ me);
if (NULL == me->ats_perf_handle)
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"Failed to create ATS performance handle \n");
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
GNUNET_break(0);
- if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
+ if (NULL != top->shutdown_task)
GNUNET_SCHEDULER_cancel (top->shutdown_task);
top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
return;
* Signature of a main function for a testcase.
*
* @param cls closure
+ * @param h testbed handle
* @param num_peers number of peers in 'peers'
* @param peers_ handle to peers run in the testbed
* @param links_succeeded the number of overlay link connection attempts that
}
}
+struct BenchmarkPeer *
+GNUNET_ATS_TEST_get_peer (int src)
+{
+ if (src > top->num_masters)
+ return NULL;
+ return &top->mps[src];
+}
+
+struct BenchmarkPartner *
+GNUNET_ATS_TEST_get_partner (int src, int dest)
+{
+ if (src > top->num_masters)
+ return NULL;
+ if (dest > top->num_slaves)
+ return NULL;
+ return &top->mps[src].partners[dest];
+}
+
+/**
+ * Create a topology for ats testing
+ *
+ * @param name test name
+ * @param cfg_file configuration file to use for the peers
+ * @param num_slaves number of slaves
+ * @param num_masters number of masters
+ * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO)
+ * @param done_cb function to call when topology is setup
+ * @param done_cb_cls cls for callback
+ * @param transport_recv_cb callback to call when data are received
+ * @param log_request_cb callback to call when logging is required
+ */
void
GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
- unsigned int num_slaves,
- unsigned int num_masters,
- int test_core,
- GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
- void *done_cb_cls,
- GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb,
- GNUNET_ATS_AddressInformationCallback log_request_cb)
+ unsigned int num_slaves,
+ unsigned int num_masters,
+ int test_core,
+ GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
+ void *done_cb_cls,
+ GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb,
+ GNUNET_ATS_AddressInformationCallback log_request_cb)
{
-
static struct GNUNET_CORE_MessageHandler handlers[] = {
{&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 },
{&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 },
event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
(void) GNUNET_TESTBED_test_run (name, cfg_file,
- num_slaves + num_masters, event_mask, &controller_event_cb, NULL,
- &main_run, NULL);
+ num_slaves + num_masters,
+ event_mask,
+ &controller_event_cb, NULL,
+ &main_run, NULL);
}
+
+/**
+ * Shutdown topology
+ */
void
GNUNET_ATS_TEST_shutdown_topology (void)
{
if (NULL == top)
return;
-
GNUNET_SCHEDULER_shutdown();
}