144 if (NULL ==
ctx->ports)
148 for (
unsigned int i = 0; i <
ctx->port_count; i++)
153 (
void *) (
long) actx->
peer,
176 if (NULL != actx->
ports)
181 actx->
ports[i] = NULL;
211 "Failed to connect to CADET service: %s\n",
216 for (
unsigned int i = 0; i <
ctx->num_peers; i++)
217 if (
op ==
ctx->ops[i])
219 ctx->cadets[i] = ca_result;
221 "...cadet %u connected\n",
224 for (
unsigned int i = 0; i <
ctx->num_peers; i++)
225 if (NULL ==
ctx->cadets[i])
229 ctx->app_main (
ctx->app_main_cls,
240 for (
unsigned int i = 0; i <
ctx->num_peers; i++)
272 unsigned int links_succeeded,
273 unsigned int links_failed)
277 if (0 != links_failed)
280 "Some links failed (%u), ending\n",
287 "Peers started %u/%u, ending\n",
293 "Testbed up, %u peers and %u links\n",
297 for (
unsigned int i = 0; i <
num_peers; i++)
305 "Connecting to cadet %u\n",
358 ctx->app_main_cls = tmain_cls;
365 while (NULL !=
ctx->ports[
ctx->port_count])
void * connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
static void cadet_disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy a connection to the CADET service.
static void * cadet_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to the CADET service.
void GNUNET_CADET_TEST_ruN(const char *testname, const char *cfgfile, unsigned int num_peers, GNUNET_CADET_TEST_AppMain tmain, void *tmain_cls, GNUNET_CADET_ConnectEventHandler connects, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_HashCode **ports)
Run a test using the given name, configuration file and number of peers.
static void cadet_connect_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Callback to be called when a service connect operation is completed.
void GNUNET_CADET_TEST_cleanup(struct GNUNET_CADET_TEST_Context *ctx)
Clean up the testbed.
static void cadet_test_run(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Callback run when the testbed is ready (peers running and connected to each other)
library for writing CADET tests
void(* GNUNET_CADET_TEST_AppMain)(void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, struct GNUNET_CADET_Handle **cadets)
Main function of a CADET test.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_ARM_Operation * op
Current operation.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static void tmain(void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **testbed_peers, struct GNUNET_CADET_Handle **cadetes)
test main: start test when all peers are connected
static struct CadetPeer * peers
Operation to get peer ids.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static unsigned int num_peers
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
CADET service; establish channels to distant peers.
void(* GNUNET_CADET_DisconnectEventHandler)(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever an MQ-channel is destroyed, unless the destruction was requested by GNUNET_C...
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
void(* GNUNET_CADET_WindowSizeEventHandler)(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel's transmission window size changes.
void *(* GNUNET_CADET_ConnectEventHandler)(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
Method called whenever a peer connects to a port in MQ-based CADET.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
#define GNUNET_log(kind,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
int GNUNET_TESTBED_test_run(const char *testname, const char *cfg_filename, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a "simple" test on the local system with a single call from 'main'.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
Opaque handle to the service.
Context for a cadet adapter callback.
struct GNUNET_CADET_TEST_Context * ctx
General context.
unsigned int peer
Peer number for the particular peer.
struct GNUNET_CADET_Port ** ports
Port handlers for open ports.
Test context for a CADET Test.
GNUNET_CADET_WindowSizeEventHandler window_changes
Function called when the transmit window size changes.
unsigned int port_count
Number of ports in ports.
struct GNUNET_TESTBED_Peer ** peers
Array of running peers.
GNUNET_CADET_DisconnectEventHandler disconnects
Cleaner for destroyed incoming tunnels.
struct GNUNET_MQ_MessageHandler * handlers
Message handlers.
unsigned int num_peers
Number of peers running, size of the arrays above.
struct GNUNET_TESTBED_Operation ** ops
Operation associated with the connection to the CADET.
void * app_main_cls
Closure for 'app_main'.
const struct GNUNET_HashCode ** ports
Application ports.
GNUNET_CADET_ConnectEventHandler connects
Handler for incoming tunnels.
struct GNUNET_CADET_Handle ** cadets
Array of handles to the CADET for each peer.
GNUNET_CADET_TEST_AppMain app_main
Main function of the test to run once all CADETs are available.
Message handler for a specific message type.
Opaque handle to an abstract operation to be executed by the testing framework.
A peer controlled by the testing framework.