$(TESTING_LIBS)
libgnunettransporttesting_la_SOURCES = \
- transport-testing.c transport-testing.h
+ transport-testing.c transport-testing.h \
+ transport-testing-filenames.c \
+ transport-testing-main.c
libgnunettransporttesting_la_LIBADD = \
libgnunettransport.la \
$(top_builddir)/src/hello/libgnunethello.la \
static struct GNUNET_SCHEDULER_Task * measure_task;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
-struct PeerContext *sender;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *sender;
-struct PeerContext *receiver;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver;
struct GNUNET_TRANSPORT_TransmitHandle *th;
unsigned long long quota_in_p2;
unsigned long long quota_out_p2;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
test_failed = GNUNET_YES;
}
const struct GNUNET_MessageHeader *message)
{
const struct TestMessage *hdr;
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
hdr = (const struct TestMessage *) message;
if (MTYPE != ntohs (message->type))
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') connected to us!\n",
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') disconnected!\n",
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
}
-void
-start_cb (struct PeerContext *p, void *cls)
+
+static void
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
"Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no,
sender_c, receiver->no, GNUNET_i2s (&receiver->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
NULL);
}
}
}
+
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
int
main (int argc, char *argv[])
{
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
check ();
static struct GNUNET_SCHEDULER_Task *measure_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
static char *cfg_file_p1;
static struct GNUNET_STATISTICS_Handle *p1_stat;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static char *cfg_file_p2;
static struct GNUNET_STATISTICS_Handle *p2_stat;
-static struct PeerContext *sender;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *sender;
-static struct PeerContext *receiver;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
}
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
if (MTYPE != ntohs (message->type))
return;
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') connected to us!\n",
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
if (NULL != p1)
{
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
GNUNET_free (sender_c);
/* Connect the peers */
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
&testing_connect_cb,
NULL);
}
static struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END };
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name, "WARNING", NULL );
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 1, cfg_file_p1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 2, cfg_file_p2);
GNUNET_PROGRAM_run ((sizeof(argv_new) / sizeof(char *)) - 1, argv_new,
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p,
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
void *cls)
{
static int started;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0],
- &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__,
- &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
- test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
- &cfg_file_p1,
- 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
- &cfg_file_p2,
- 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
+ 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
+ 2);
ret = check ();
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc1;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc2;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
th = NULL;
}
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
if (NULL != cc2)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc2);
cc2 = NULL;
}
if (NULL != cc1)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc1);
cc1 = NULL;
}
if (NULL != th)
th = NULL;
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
static int connected = GNUNET_NO;
if ((cls == cc1) && (NULL != cc2))
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc2);
}
if ((cls == cc2) && (NULL != cc1))
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc1);
}
cc1 = NULL;
cc2 = NULL;
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
cc1 =
- GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
+ GNUNET_TRANSPORT_TESTING_connect_peers (p2,
+ p1,
+ &testing_connect_cb,
cc1);
cc2 =
- GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
cc2);
}
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1, 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
-
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
#include "gnunet_transport_service.h"
#include "transport-testing.h"
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/**
* How long until we give up on transmitting the message?
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel(cc);
cc = NULL;
}
if (p1 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
GNUNET_TRANSPORT_blacklist_cancel (blacklist_p2);
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
connected = GNUNET_YES;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
const struct
GNUNET_PeerIdentity * pid)
{
- struct PeerContext * p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext * p = cls;
int res = GNUNET_SYSERR;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &end_badly,
+ NULL);
connected = GNUNET_NO;
blacklist_request_p1 = GNUNET_NO;
blacklist_request_p2 = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer1.conf", 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_api_tcp_peer1.conf", 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer2.conf", 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_api_tcp_peer2.conf", 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
blacklist_p1 = GNUNET_TRANSPORT_blacklist (p1->cfg,
- &blacklist_cb,
- p1);
+ &blacklist_cb,
+ p1);
blacklist_p2 = GNUNET_TRANSPORT_blacklist (p2->cfg,
- &blacklist_cb,
- p2);
+ &blacklist_cb,
+ p2);
GNUNET_assert (blacklist_p1 != NULL);
GNUNET_assert (blacklist_p2 != NULL);
static struct GNUNET_SCHEDULER_Task * send_task;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
int shutdown_;
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
/* success */
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
static void
stop_peer (void *cls)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no,
GNUNET_i2s (&p->id));
shutdown_ = GNUNET_YES;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
GNUNET_assert (p2 == NULL);
}
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Fail! Could not start peers!\n");
if (die_task != NULL)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
-
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
-
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
}
GNUNET_SCHEDULER_cancel (send_task);
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
if (NULL != th)
GNUNET_TRANSPORT_TESTING_done (tth);
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
}
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
if (started != 2)
return;
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p2,
+ p1,
+ &testing_connect_cb,
NULL);
}
tth = GNUNET_TRANSPORT_TESTING_init ();
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
int res;
int ret = 0;
- test_plugin = NULL;
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
return 0;
}
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
GNUNET_free (cfg_file_p1);
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
static size_t
notify_request_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static size_t
notify_response_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
struct GNUNET_TIME_Relative duration;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
NULL);
}
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
s_connected = GNUNET_NO;
s_sending = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1, 1,
¬ify_receive, ¬ify_connect,
¬ify_disconnect, &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2, 2,
¬ify_receive, ¬ify_connect,
¬ify_disconnect, &start_cb,
NULL);
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
static int c;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
c++;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
&testing_connect_cb,
NULL);
s_connected = GNUNET_NO;
s_sending = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1, 1,
¬ify_receive, ¬ify_connect,
¬ify_disconnect, &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2, 2,
¬ify_receive, ¬ify_connect,
¬ify_disconnect, &start_cb,
NULL);
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
th = NULL;
if (NULL != p1)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
if (NULL != p2)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
if (NULL != pmc_p1)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
{
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
s_connected = GNUNET_NO;
s_sending = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
pmc_p1 = GNUNET_TRANSPORT_monitor_peers (p1->cfg,
NULL,
NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 started\n");
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
pmc_p2 = GNUNET_TRANSPORT_monitor_peers (p2->cfg,
NULL,
ok = 1;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
/**
* Context of peer 1
*/
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
/**
* Configuration file of peer 1
/**
* Context of peer 2
*/
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
/**
* Configuration file of peer 1
/**
* Transport testing handle
*/
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/*
* Total amount of bytes sent
}
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
ok = 0;
for (i = 0; i < TOTAL_MSGS; i++)
}
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
ok = GNUNET_SYSERR;
}
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
return;
test_connected = GNUNET_NO;
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
NULL);
}
GNUNET_GETOPT_OPTION_END
};
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0],
- &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__,
- &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
- test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
#if WRITECONFIG
setTransportOptions ("test_transport_api_data.conf");
static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
static int p1_connected;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static int p2_connected;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
}
if (NULL != p1)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (NULL != p2)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
end ();
static void
-restart_cb (struct PeerContext *p, void *cls)
+restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Restarted peer %u (`%4s'), issuing reconnect\n",
static void
-restart (struct PeerContext *p,
- const char *cfg_file)
+restart (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Restarting peer %u (`%4s')\n",
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
- cfg_file,
&restart_cb,
p);
}
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
if (restarted == GNUNET_NO)
{
restarted = GNUNET_YES;
- restart (p1, cfg_file_p1);
+ restart (p1);
return;
}
else
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
{
t->no, GNUNET_i2s (peer));
GNUNET_free (ps);
- if ((restarted == GNUNET_YES) && ((p1_connected == GNUNET_YES) && (p2_connected == GNUNET_YES)))
+ if ( (restarted == GNUNET_YES) &&
+ (p1_connected == GNUNET_YES) &&
+ (p2_connected == GNUNET_YES) )
{
/* Peer was restarted and we received 3 connect messages (2 from first connect, 1 from reconnect) */
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
if ( (NULL != p1) &&
(0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))))
send_task = NULL;
}
+
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peers connected: %u (%s) <-> %u (%s)\n",
p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
p1_connected = GNUNET_NO;
p2_connected = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Fail! Could not start peers!\n");
if (die_task != NULL)
GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_now (&end_badly,
+ NULL);
return;
}
}
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
}
if (NULL != p1)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (NULL != p2)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
end ();
static void
-restart_cb (struct PeerContext *p,
+restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
void *cls)
{
static int c;
static void
-restart (struct PeerContext *p,
- const char *cfg_file)
+restart (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
{
GNUNET_assert (NULL != p);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
- cfg_file,
&restart_cb,
p);
}
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
if (restarted == GNUNET_NO)
{
restarted = GNUNET_YES;
- restart (p1, cfg_file_p1);
- restart (p2, cfg_file_p2);
+ restart (p1);
+ restart (p2);
return;
}
else
size_t size,
void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
static int c;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
c++;
if (0 == memcmp (peer,
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
static struct GNUNET_SCHEDULER_Task * timer_task;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
die_task = NULL;
}
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
if (disconnects == 0)
ok = 0;
timer_task = NULL;
}
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
GNUNET_TRANSPORT_TESTING_done (tth);
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- ¬ify_receive, ¬ify_connect,
- ¬ify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ ¬ify_receive,
+ ¬ify_connect,
+ ¬ify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
static struct GNUNET_SCHEDULER_Task * die_task;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
char *cfg_file_p1;
}
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
}
void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
char *test_name;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/**
* How long until we give up on transmitting the message?
if (cc != NULL )
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
if (cc != NULL )
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL )
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL )
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
static void
-testing_connect_cb(struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
static void
-start_cb(struct PeerContext *p, void *cls)
+start_cb(struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
started++;
sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free(sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
- NULL );
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
+ NULL);
}
-static int check_blacklist_config (char *cfg_file,
- struct GNUNET_PeerIdentity *peer, struct GNUNET_PeerIdentity *bl_peer)
+static int
+check_blacklist_config (const char *cfg_file,
+ struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_PeerIdentity *bl_peer)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
char *section;
{
/* Try to connect peers successfully */
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- "test_transport_blacklisting_cfg_peer1.conf", 1, NULL, NULL, NULL,
- &start_cb, NULL );
+ "test_transport_blacklisting_cfg_peer1.conf",
+ 1,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- "test_transport_blacklisting_cfg_peer2.conf", 2, NULL, NULL, NULL,
- &start_cb, NULL );
+ "test_transport_blacklisting_cfg_peer2.conf",
+ 2,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_outbound_bl_full"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_outbound_bl_full"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_full.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1 , 1, NULL, NULL, NULL, &start_cb, NULL );
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_full.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_p1,
+ 1, NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
- (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
+ (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
else if (0
== strcmp (test_name, "test_transport_blacklisting_outbound_bl_plugin"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_plugin.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_plugin.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1, NULL,
- NULL, NULL, &start_cb, NULL );
+ cfg_p1,
+ 1,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p2, 2,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
- (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
+ (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_inbound_bl_full"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_inbound_bl_full"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p1, 1,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL,
- NULL, &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_inbound_bl_plugin"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_inbound_bl_plugin"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p1, 1,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL,
- NULL, &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL,
+ NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_multiple_plugins"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_multiple_plugins"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_multiple_plugins.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_multiple_plugins.conf";
+ const char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_multiple_plugins.conf";
+ const char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_multiple_plugins.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1,
- NULL, NULL, NULL, &start_cb, NULL );
+ cfg_p1, 1,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2,
- NULL, NULL, NULL, &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
- (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)))
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
+ (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)))
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL );
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
}
else
{
GNUNET_break (0);
- GNUNET_SCHEDULER_add_now (&end, NULL );
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
if ((NULL == p1) || (NULL == p2))
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to start peers\n");
ok = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL );
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
timeout_task = GNUNET_SCHEDULER_add_delayed (CONNECT_TIMEOUT,
- &connect_timeout, NULL );
+ &connect_timeout,
+ NULL);
stage++;
return;
}
if (cc != NULL )
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
{
ok = 1;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv0[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv0[0]);
GNUNET_log_setup ("test-transport-api-blacklisting", "WARNING", NULL );
struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int connected = GNUNET_NO;
"Fail! Stopping peers\n");
timeout_task = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
ret = GNUNET_SYSERR;
GNUNET_assert (p1 != NULL);
GNUNET_assert (p1->th != NULL);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
i++;
if (i <= ITERATIONS)
static struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int connected = GNUNET_NO;
static void
end ()
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping peers\n");
if (timeout_task != NULL)
GNUNET_SCHEDULER_cancel (timeout_task);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
}
end_badly ()
{
timeout_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout! Stopping peers\n");
if (NULL != cc)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' connected \n",
GNUNET_i2s (peer));
connected++;
static void
-notify_disconnect (void *cls,
+notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' disconnected \n",
GNUNET_i2s (peer));
}
static void
-notify_receive (void *cls,
+notify_receive (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Receiving\n");
}
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%s') started\n", p->no,
GNUNET_i2s (&p->id));
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
&testing_connect_cb,
NULL);
}
int
main (int argc, char *argv[])
{
- char *const argv_1[] = {
+ char *const argv_1[] = {
"test_transport_testing",
"-c",
"test_transport_api_data.conf",
"WARNING",
NULL);
GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1,
- "test_transport_testing", "nohelp", options,
+ "test_transport_testing", "nohelp", options,
&run, &ret);
return ret;
struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int ret = 0;
if (timeout_task != NULL)
GNUNET_SCHEDULER_cancel (timeout_task);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
GNUNET_TRANSPORT_TESTING_done (tth);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
if (NULL != p)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
}
static void
-restart_cb (struct PeerContext *p, void *cls)
+restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully restarted\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%s') successfully restarted\n",
p->no,
GNUNET_i2s (&p->id));
-
ret = 0;
GNUNET_SCHEDULER_add_now (&end, NULL);
}
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
- NULL,
&restart_cb,
p);
}
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n",
p->no,
GNUNET_assert (NULL != tth);
timeout_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL);
-
- p = GNUNET_TRANSPORT_TESTING_start_peer(tth, cfgfile, 1,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ &end_badly,
+ NULL);
+ p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
+ cfgfile,
+ 1,
NULL, /* receive cb */
NULL, /* connect cb */
NULL, /* disconnect cb */
struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int ret = 0;
if (timeout_task != NULL)
GNUNET_SCHEDULER_cancel (timeout_task);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
GNUNET_TRANSPORT_TESTING_done (tth);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
if (NULL != p)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n",
p->no,
GNUNET_assert (NULL != tth);
timeout_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ &end_badly,
+ NULL);
- p = GNUNET_TRANSPORT_TESTING_start_peer(tth, cfgfile, 1,
+ p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
+ cfgfile,
+ 1,
NULL, /* receive cb */
NULL, /* connect cb */
NULL, /* disconnect cb */
- start_cb, /* startup cb */
+ &start_cb, /* startup cb */
NULL); /* closure */
if (NULL == p)
{
--- /dev/null
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file transport-testing-filenames.c
+ * @brief convenience string manipulation functions for tests
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#include "transport-testing.h"
+
+
+/**
+ * Removes all directory separators from absolute filename
+ *
+ * @param file the absolute file name, e.g. as found in argv[0]
+ * @return extracted file name, has to be freed by caller
+ */
+static char *
+extract_filename (const char *file)
+{
+ char *pch = GNUNET_strdup (file);
+ char *backup = pch;
+ char *filename = NULL;
+ char *res;
+
+#if WINDOWS
+ if ((strlen (pch) >= 3) && pch[1] == ':')
+ {
+ if (NULL != strstr (pch, "\\"))
+ {
+ pch = strtok (pch, "\\");
+ while (pch != NULL)
+ {
+ pch = strtok (NULL, "\\");
+ if (pch != NULL)
+ filename = pch;
+ }
+ }
+ }
+ if (filename != NULL)
+ pch = filename; /* If we miss the next condition, filename = pch will
+ * not harm us.
+ */
+#endif
+ if (NULL != strstr (pch, "/"))
+ {
+ pch = strtok (pch, "/");
+ while (pch != NULL)
+ {
+ pch = strtok (NULL, "/");
+ if (pch != NULL)
+ {
+ filename = pch;
+ }
+ }
+ }
+ else
+ filename = pch;
+
+ res = GNUNET_strdup (filename);
+ GNUNET_free (backup);
+ return res;
+}
+
+
+/**
+ * Extracts the test filename from an absolute file name and removes
+ * the extension
+ *
+ * @param file absolute file name
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_test_name (const char *file)
+{
+ char *backup = extract_filename (file);
+ char *filename = backup;
+ char *dotexe;
+ char *ret;
+
+ if (NULL == filename)
+ return NULL;
+
+ /* remove "lt-" */
+ filename = strstr (filename, "test");
+ if (NULL == filename)
+ {
+ GNUNET_free (backup);
+ return NULL;
+ }
+
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+ ret = GNUNET_strdup (filename);
+ GNUNET_free (backup);
+ return ret;
+}
+
+
+/**
+ * Extracts the filename from an absolute file name and removes the extension
+ *
+ * @param file absolute file name
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file)
+{
+ char *src = extract_filename (file);
+ char *split;
+
+ split = strstr (src, ".");
+ if (NULL != split)
+ split[0] = '\0';
+ return src;
+}
+
+
+/**
+ * Extracts the plugin name from an absolute file name and the test name
+ *
+ * @param file absolute file name
+ * @param test test name
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
+ const char *test)
+{
+ char *filename;
+ char *dotexe;
+ char *e = extract_filename (file);
+ char *t = extract_filename (test);
+ char *ret;
+
+ if (NULL == e)
+ goto fail;
+ /* remove "lt-" */
+ filename = strstr (e, "tes");
+ if (NULL == filename)
+ goto fail;
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+
+ /* find last _ */
+ filename = strstr (filename, t);
+ if (NULL == filename)
+ goto fail;
+ /* copy plugin */
+ filename += strlen (t);
+ if ('\0' != *filename)
+ filename++;
+ ret = GNUNET_strdup (filename);
+ goto suc;
+fail:
+ ret = NULL;
+suc:
+ GNUNET_free (t);
+ GNUNET_free (e);
+ return ret;
+}
+
+
+/**
+ * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
+ * if existing ".exe"-prefix and adds the peer-number
+ *
+ * @param file filename of the test, e.g. argv[0]
+ * @param count peer number
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
+ int count)
+{
+ char *filename = extract_filename (file);
+ char *backup = filename;
+ char *dotexe;
+ char *ret;
+
+ if (NULL == filename)
+ return NULL;
+ /* remove "lt-" */
+ filename = strstr (filename, "test");
+ if (NULL == filename)
+ goto fail;
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+ GNUNET_asprintf (&ret,
+ "%s_peer%u.conf",
+ filename,
+ count);
+ GNUNET_free (backup);
+ return ret;
+fail:
+ GNUNET_free (backup);
+ return NULL;
+}
+
+
+/* end of transport-testing-filenames.c */
--- /dev/null
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2016 GNUnet e.V.
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file transport-testing-main.c
+ * @brief convenience main function for tests
+ * @author Christian Grothoff
+ */
+#include "transport-testing.h"
+
+
+/**
+ * Setup testcase. Calls @a check with the data the test needs.
+ *
+ * @param argv0 binary name (argv[0])
+ * @param filename source file name (__FILE__)
+ * @param num_peers number of peers to start
+ * @param check main function to run
+ * @param check_cls closure for @a check
+ * @return #GNUNET_OK on success
+ */
+int
+GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
+ const char *filename,
+ unsigned int num_peers,
+ GNUNET_TRANSPORT_TESTING_CheckCallback check,
+ void *check_cls)
+{
+ return GNUNET_SYSERR;
+}
+
+/* end of transport-testing-main.c */
/*
This file is part of GNUnet.
- Copyright (C) 2006, 2009, 2015 GNUnet e.V.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
-
/**
* @file transport-testing.c
* @brief testing lib for transport service
- *
* @author Matthias Wachs
+ * @author Christian Grothoff
*/
#include "transport-testing.h"
#define LOG(kind,...) GNUNET_log_from(kind, "transport-testing", __VA_ARGS__)
-static struct PeerContext *
-find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *
+find_peer_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *t = tth->p_head;
-
- while (t != NULL)
- {
- if (0 == memcmp (&t->id, peer, sizeof (struct GNUNET_PeerIdentity)))
- break;
- t = t->next;
- }
-
- return t;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t;
+
+ for (t = tth->p_head; NULL != t; t = t->next)
+ if (0 == memcmp (&t->id,
+ peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ return t;
+ return NULL;
}
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext *p2)
+find_connecting_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2)
{
- GNUNET_assert (tth != NULL);
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
- while (cc != NULL)
+ for (cc = tth->cc_head; NULL != cc; cc = cc->next)
{
- if ((cc->p1 == p1) && (cc->p2 == p2))
- break;
- if ((cc->p1 == p2) && (cc->p2 == p1))
- break;
- cc = cc->next;
+ if ( (cc->p1 == p1) &&
+ (cc->p2 == p2) )
+ return cc;
+ if ( (cc->p1 == p2) &&
+ (cc->p2 == p1) )
+ return cc;
}
-
- return cc;
+ return NULL;
}
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *p2_s;
- struct PeerContext *p2;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
- GNUNET_assert (NULL != p);
- GNUNET_assert (NULL != p->tth);
- p2 = find_peer_context (p->tth, peer);
- if (p->nc != NULL)
- p->nc (p->cb_cls, peer);
+ p2 = find_peer_context (p->tth,
+ peer);
+ if (NULL != p->nc)
+ p->nc (p->cb_cls,
+ peer);
if (p2 != NULL)
- GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_asprintf (&p2_s,
+ "%u (`%s')",
+ p2->no,
+ GNUNET_i2s (&p2->id));
else
- GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
+ GNUNET_asprintf (&p2_s,
+ "`%s'",
+ GNUNET_i2s (peer));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peers %s connected to peer %u (`%s')\n",
p2_s,
GNUNET_free (p2_s);
/* Find ConnectingContext */
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = find_connecting_context (p->tth, p, p2);
-
- if (cc == NULL)
+ cc = find_connecting_context (p->tth,
+ p,
+ p2);
+ if (NULL == cc)
return;
-
if (p == cc->p1)
cc->p1_c = GNUNET_YES;
-
if (p == cc->p2)
cc->p2_c = GNUNET_YES;
- if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
+ if ( (cc->p1_c == GNUNET_YES) &&
+ (cc->p2_c == GNUNET_YES) )
{
- cc->cb (cc->p1, cc->p2, cc->cb_cls);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (p->tth, cc);
+ cc->cb (cc->cb_cls);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
}
}
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
-
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ char *p2_s;
/* Find PeerContext */
int no = 0;
- struct PeerContext *p2 = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = NULL;
- if (p != NULL)
+ if (NULL != p)
{
- GNUNET_assert (p->tth != NULL);
- p2 = find_peer_context (p->tth, peer);
+ p2 = find_peer_context (p->tth,
+ peer);
no = p->no;
}
- char *p2_s;
-
if (p2 != NULL)
- GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_asprintf (&p2_s,
+ "%u (`%s')",
+ p2->no,
+ GNUNET_i2s (&p2->id));
else
- GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
+ GNUNET_asprintf (&p2_s,
+ "`%s'",
+ GNUNET_i2s (peer));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peers %s disconnected from peer %u (`%s')\n",
p2_s,
GNUNET_i2s (&p->id));
GNUNET_free (p2_s);
- if (p == NULL)
+ if (NULL == p)
return;
- if (p->nd != NULL)
- p->nd (p->cb_cls, peer);
+ if (NULL != p->nd)
+ p->nd (p->cb_cls,
+ peer);
}
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
- if (p == NULL)
+ if (NULL == p)
return;
- if (p->rec != NULL)
- p->rec (p->cb_cls, peer, message);
+ if (NULL != p->rec)
+ p->rec (p->cb_cls,
+ peer,
+ message);
}
get_hello (void *cb_cls,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cb_cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cb_cls;
struct GNUNET_PeerIdentity hello_id;
- GNUNET_assert (message != NULL);
GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &hello_id));
- GNUNET_assert (0 == memcmp (&hello_id, &p->id, sizeof (hello_id)));
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) message,
+ &hello_id));
+ GNUNET_assert (0 == memcmp (&hello_id,
+ &p->id,
+ sizeof (hello_id)));
GNUNET_free_non_null (p->hello);
p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message);
"Peer %u (`%s') successfully started\n",
p->no,
GNUNET_i2s (&p->id));
- p->start_cb (p, p->cb_cls);
+ p->start_cb (p,
+ p->cb_cls);
p->start_cb = NULL;
}
}
-/**
- * Offer the current HELLO of P2 to P1.
- *
- * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest `
- */
-static void
-offer_hello (void *cls);
-
-
-/**
- * Function called after the HELLO was passed to the
- * transport service.
- */
-static void
-hello_offered (void *cls)
-{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
-
- cc->oh = NULL;
- cc->tct =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &offer_hello,
- cc);
-}
-
-
-/**
- * Offer the current HELLO of P2 to P1.
- *
- * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
- */
-static void
-offer_hello (void *cls)
-{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
- struct PeerContext *p1 = cc->p1;
- struct PeerContext *p2 = cc->p2;
-
- cc->tct = NULL;
- {
- char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
- p1->no,
- GNUNET_i2s (&p1->id),
- p2->no,
- p2_s,
- GNUNET_HELLO_size (cc->p2->hello));
- GNUNET_free (p2_s);
- }
-
- if (NULL != cc->oh)
- GNUNET_TRANSPORT_offer_hello_cancel (cc->oh);
- cc->oh =
- GNUNET_TRANSPORT_offer_hello (cc->p1->cfg,
- (const struct GNUNET_MessageHeader *) cc->p2->hello,
- &hello_offered,
- cc);
-}
-
-
/**
* Start a peer with the given configuration
* @param tth the testing handle
* @param cb_cls closure for callback
* @return the peer context
*/
-struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+struct GNUNET_TRANSPORT_TESTING_PeerContext *
+GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
const char *cfgname,
int peer_id,
GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd,
- GNUNET_TRANSPORT_TESTING_start_cb start_cb,
+ GNUNET_TRANSPORT_TESTING_StartCallback start_cb,
void *cb_cls)
{
char *emsg = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
struct GNUNET_PeerIdentity *dummy;
- GNUNET_assert (NULL != tth);
- GNUNET_assert (NULL != tth->tl_system);
-
- if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
+ if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"File not found: `%s'\n",
return NULL;
}
- struct PeerContext *p = GNUNET_new (struct PeerContext);
- GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p);
+ p = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_PeerContext);
+ p->tth = tth;
+ p->nc = nc;
+ p->nd = nd;
+ p->rec = rec;
+ p->start_cb = start_cb;
+ if (cb_cls != NULL)
+ p->cb_cls = cb_cls;
+ else
+ p->cb_cls = p;
+ GNUNET_CONTAINER_DLL_insert (tth->p_head,
+ tth->p_tail,
+ p);
/* Create configuration and call testing lib to modify it */
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_load (p->cfg, cfgname));
- if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg))
+ if (GNUNET_SYSERR ==
+ GNUNET_TESTING_configuration_create (tth->tl_system,
+ p->cfg))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to create unique configuration based on `%s'\n",
cfgname);
+ GNUNET_CONFIGURATION_destroy (p->cfg);
GNUNET_free (p);
return NULL;
}
p->no = peer_id;
/* Configure peer with configuration */
p->peer = GNUNET_TESTING_peer_configure (tth->tl_system,
- p->cfg, p->no, NULL, &emsg);
+ p->cfg,
+ p->no,
+ NULL,
+ &emsg);
if (NULL == p->peer)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to create unique configuration based on `%s': `%s'\n",
cfgname,
emsg);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
GNUNET_free_non_null (emsg);
return NULL;
}
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to create unique configuration based on `%s'\n",
cfgname);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
- memset(&dummy, '\0', sizeof (dummy));
- GNUNET_TESTING_peer_get_identity (p->peer, &p->id);
- if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity)))
+ memset (&dummy,
+ '\0',
+ sizeof (dummy));
+ GNUNET_TESTING_peer_get_identity (p->peer,
+ &p->id);
+ if (0 == memcmp (&dummy,
+ &p->id,
+ sizeof (struct GNUNET_PeerIdentity)))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to obtain peer identity for peer %u\n",
p->no);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
- else
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u configured with identity `%s'\n",
- p->no,
- GNUNET_i2s_full (&p->id));
- }
-
- p->tth = tth;
- p->nc = nc;
- p->nd = nd;
- p->rec = rec;
- p->start_cb = start_cb;
- if (cb_cls != NULL)
- p->cb_cls = cb_cls;
- else
- p->cb_cls = p;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u configured with identity `%s'\n",
+ p->no,
+ GNUNET_i2s_full (&p->id));
- p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p,
+ p->th = GNUNET_TRANSPORT_connect (p->cfg,
+ NULL,
+ p,
¬ify_receive,
¬ify_connect,
¬ify_disconnect);
"Failed to connect to transport service for peer `%s': `%s'\n",
cfgname,
emsg);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
p->ats = GNUNET_ATS_connectivity_init (p->cfg);
"Failed to connect to ATS service for peer `%s': `%s'\n",
cfgname,
emsg);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg,
&get_hello,
p);
GNUNET_assert (p->ghh != NULL);
-
return p;
}
/**
- * Restart the given peer
+ * Stops and restarts the given peer, sleeping (!) for 5s in between.
*
* @param p the peer
- * @param cfgname the cfg file used to restart
* @param restart_cb callback to call when restarted
* @param cb_cls callback closure
* @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
*/
int
-GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
- const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ GNUNET_TRANSPORT_TESTING_StartCallback restart_cb,
void *cb_cls)
{
- GNUNET_assert (NULL != p->peer);
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Restarting peer %u (`%s')\n",
- p->no,
- GNUNET_i2s (&p->id));
-
/* shutdown */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Stopping peer %u (`%s')\n",
GNUNET_ATS_connectivity_done (p->ats);
p->ats = NULL;
}
-
- if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop (p->peer))
+ if (GNUNET_SYSERR ==
+ GNUNET_TESTING_peer_stop (p->peer))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Failed to stop peer %u (`%s')\n",
sleep (5); // YUCK!
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarting peer %u (`%s')\n",
+ p->no,
+ GNUNET_i2s (&p->id));
/* restart */
if (GNUNET_SYSERR == GNUNET_TESTING_peer_start (p->peer))
{
/**
* Shutdown the given peer
*
- * @param tth testing handle
* @param p the peer
*/
void
-GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p)
+GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
{
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
+
if (NULL != p->ghh)
{
GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
}
if (NULL != p->peer)
{
- if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer))
+ if (GNUNET_OK !=
+ GNUNET_TESTING_peer_stop (p->peer))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Testing lib failed to stop peer %u (`%s') \n", p->no,
+ "Testing lib failed to stop peer %u (`%s')\n",
+ p->no,
GNUNET_i2s (&p->id));
}
GNUNET_TESTING_peer_destroy (p->peer);
tth->p_tail,
p);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%s') stopped \n",
+ "Peer %u (`%s') stopped\n",
p->no,
GNUNET_i2s (&p->id));
GNUNET_free (p);
}
+/**
+ * Offer the current HELLO of P2 to P1.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
+ */
+static void
+offer_hello (void *cls);
+
+
+/**
+ * Function called after the HELLO was passed to the
+ * transport service.
+ */
+static void
+hello_offered (void *cls)
+{
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
+
+ cc->oh = NULL;
+ cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &offer_hello,
+ cc);
+}
+
+
+/**
+ * Offer the current HELLO of P2 to P1.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
+ */
+static void
+offer_hello (void *cls)
+{
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
+
+ cc->tct = NULL;
+ {
+ char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
+ p1->no,
+ GNUNET_i2s (&p1->id),
+ p2->no,
+ p2_s,
+ GNUNET_HELLO_size (cc->p2->hello));
+ GNUNET_free (p2_s);
+ }
+
+ if (NULL != cc->oh)
+ GNUNET_TRANSPORT_offer_hello_cancel (cc->oh);
+ cc->oh =
+ GNUNET_TRANSPORT_offer_hello (cc->p1->cfg,
+ (const struct GNUNET_MessageHeader *) cc->p2->hello,
+ &hello_offered,
+ cc);
+}
+
+
/**
* Initiate a connection from p1 to p2 by offering p1 p2's HELLO message
*
* @return a connect request handle
*/
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext *p2,
- GNUNET_TRANSPORT_TESTING_connect_cb cb,
+GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
+ GNUNET_SCHEDULER_TaskCallback cb,
void *cls)
{
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
cc->ats_sh = GNUNET_ATS_connectivity_suggest (cc->p1->ats,
&p2->id,
1);
-
LOG (GNUNET_ERROR_TYPE_DEBUG,
"New connect request %p\n",
cc);
-
return cc;
}
* @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
{
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Canceling connect request %p!\n",
- cc);
+ "Canceling connect request!\n");
if (NULL != cc->tct)
{
GNUNET_SCHEDULER_cancel (cc->tct);
GNUNET_ATS_connectivity_suggest_cancel (cc->ats_sh);
cc->ats_sh = NULL;
}
-
GNUNET_CONTAINER_DLL_remove (tth->cc_head,
tth->cc_tail,
cc);
/**
* Clean up the transport testing
+ *
* @param tth transport testing handle
*/
void
-GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
+GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth)
{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head;
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct = NULL;
- struct PeerContext *p = tth->p_head;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t;
- while (cc != tth->cc_tail)
+ cc = tth->cc_head;
+ while (NULL != cc)
{
ct = cc->next;
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Developer forgot to cancel connect request %p!\n",
- cc);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth,
- cc);
+ "Developer forgot to cancel connect request!\n");
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = ct;
}
-
+ p = tth->p_head;
while (NULL != p)
{
t = p->next;
LOG (GNUNET_ERROR_TYPE_ERROR,
"Developer forgot to stop peer!\n");
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
p = t;
}
-
GNUNET_TESTING_system_destroy (tth->tl_system,
GNUNET_YES);
GNUNET_free (tth);
- tth = NULL;
}
/**
* Initialize the transport testing
+ *
* @return transport testing handle
*/
-struct GNUNET_TRANSPORT_TESTING_handle *
+struct GNUNET_TRANSPORT_TESTING_Handle *
GNUNET_TRANSPORT_TESTING_init ()
{
- struct GNUNET_TRANSPORT_TESTING_handle *tth;
-
- /* prepare hostkeys */
- tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle);
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth;
- /* Init testing the testing lib */
+ tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_Handle);
tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
NULL,
NULL,
if (NULL == tth->tl_system)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to initialize testing library!\n"));
+ "Failed to initialize testing library!\n");
GNUNET_free (tth);
return NULL;
}
-
return tth;
}
-
-/*
- * Some utility functions
- */
-
-/**
- * Removes all directory separators from absolute filename
- *
- * @param file the absolute file name, e.g. as found in argv[0]
- * @return extracted file name, has to be freed by caller
- */
-static char *
-extract_filename (const char *file)
-{
- char *pch = GNUNET_strdup (file);
- char *backup = pch;
- char *filename = NULL;
- char *res;
-#if WINDOWS
- if ((strlen (pch) >= 3) && pch[1] == ':')
- {
- if (NULL != strstr (pch, "\\"))
- {
- pch = strtok (pch, "\\");
- while (pch != NULL)
- {
- pch = strtok (NULL, "\\");
- if (pch != NULL)
- filename = pch;
- }
- }
- }
- if (filename != NULL)
- pch = filename; /* If we miss the next condition, filename = pch will
- * not harm us.
- */
-#endif
- if (NULL != strstr (pch, "/"))
- {
- pch = strtok (pch, "/");
- while (pch != NULL)
- {
- pch = strtok (NULL, "/");
- if (pch != NULL)
- {
- filename = pch;
- }
- }
- }
- else
- filename = pch;
-
- res = GNUNET_strdup (filename);
- GNUNET_free (backup);
- return res;
-}
-
-
-/**
- * Extracts the test filename from an absolute file name and removes
- * the extension
- *
- * @param file absolute file name
- * @param dest where to store result
- */
-void
-GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
- char **dest)
-{
- char *filename = extract_filename (file);
- char *backup = filename;
- char *dotexe;
-
- if (filename == NULL)
- goto fail;
-
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (filename == NULL)
- goto fail;
-
- /* remove ".exe" */
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- goto suc;
-
-fail:
- (*dest) = NULL;
- return;
-
-suc:
- /* create filename */
- GNUNET_asprintf (dest, "%s", filename);
- GNUNET_free (backup);
-}
-
-
-/**
- * Extracts the filename from an absolute file name and removes the extension
- *
- * @param file absolute file name
- * @param dest where to store result
- */
-void
-GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file,
- char **dest)
-{
- char *src = extract_filename (file);
- char *split;
-
- split = strstr (src, ".");
- if (split != NULL)
- {
- split[0] = '\0';
- }
- GNUNET_asprintf (dest, "%s", src);
- GNUNET_free (src);
-}
-
-
-/**
- * Extracts the plugin name from an absolute file name and the test name
- *
- * @param file absolute file name
- * @param test test name
- * @param dest where to store result
- */
-void
-GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
- const char *test,
- char **dest)
-{
- char *filename;
- char *dotexe;
- char *e = extract_filename (file);
- char *t = extract_filename (test);
-
- if (NULL == e)
- goto fail;
- /* remove "lt-" */
- filename = strstr (e, "tes");
- if (NULL == filename)
- goto fail;
- /* remove ".exe" */
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- /* find last _ */
- filename = strstr (filename, t);
- if (NULL == filename)
- goto fail;
- /* copy plugin */
- filename += strlen (t);
- if ('\0' != *filename)
- filename++;
- GNUNET_asprintf (dest, "%s", filename);
- goto suc;
-fail:
- (*dest) = NULL;
-suc:
- GNUNET_free (t);
- GNUNET_free (e);
-}
-
-
-/**
- * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
- * if existing ".exe"-prefix and adds the peer-number
- *
- * @param file filename of the test, e.g. argv[0]
- * @param dest where to write the filename
- * @param count peer number
- */
-void
-GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
- char **dest,
- int count)
-{
- char *filename = extract_filename (file);
- char *backup = filename;
- char *dotexe;
-
- if (NULL == filename)
- goto fail;
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (NULL == filename)
- goto fail;
- /* remove ".exe" */
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
- GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count);
- GNUNET_free (backup);
- return;
-fail:
- (*dest) = NULL;
- GNUNET_free (backup);
-}
-
-
/* end of transport-testing.c */
/*
This file is part of GNUnet.
- Copyright (C) 2006, 2009, 2015 GNUnet e.V.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
/**
* @file transport-testing.h
* @brief testing lib for transport service
- *
* @author Matthias Wachs
+ * @author Christian Grothoff
*/
+#ifndef TRANSPORT_TESTING_H
+#define TRANSPORT_TESTING_H
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_testing_lib.h"
-struct GNUNET_TRANSPORT_TESTING_ConnectRequest;
-
-
/**
* Context for a single peer
*/
-struct PeerContext;
+struct GNUNET_TRANSPORT_TESTING_PeerContext;
/**
- * Callback when two peers are connected and both have called the connect callback
- * to notify clients about a new peer
+ * Definition for a transport testing handle
*/
-typedef void
-(*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext *p,
- void *cls);
+struct GNUNET_TRANSPORT_TESTING_Handle;
+
/**
* Callback when two peers are connected and both have called the connect callback
* to notify clients about a new peer
*/
typedef void
-(*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls);
-
+(*GNUNET_TRANSPORT_TESTING_StartCallback) (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ void *cls);
-/**
- * Definition for a transport testing handle
- */
-struct GNUNET_TRANSPORT_TESTING_handle;
/**
* Context for a single peer
*/
-struct PeerContext
+struct GNUNET_TRANSPORT_TESTING_PeerContext
{
/**
* Next element in the DLL
*/
- struct PeerContext *next;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *next;
/**
* Previous element in the DLL
*/
- struct PeerContext *prev;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *prev;
/**
* Transport testing handle this peer belongs to
*/
- struct GNUNET_TRANSPORT_TESTING_handle *tth;
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/**
* Peer's configuration
/**
* Startup completed callback
*/
- GNUNET_TRANSPORT_TESTING_start_cb start_cb;
+ GNUNET_TRANSPORT_TESTING_StartCallback start_cb;
/**
* Peers HELLO Message
};
+/**
+ * Handle for a request to connect two peers.
+ */
struct GNUNET_TRANSPORT_TESTING_ConnectRequest
{
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
- struct PeerContext *p1;
- struct PeerContext *p2;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
struct GNUNET_SCHEDULER_Task *tct;
struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
struct GNUNET_TRANSPORT_OfferHelloHandle *oh;
- GNUNET_TRANSPORT_TESTING_connect_cb cb;
+ GNUNET_SCHEDULER_TaskCallback cb;
void *cb_cls;
int p1_c;
int p2_c;
};
-struct GNUNET_TRANSPORT_TESTING_handle
+/**
+ * Handle for a test run.
+ */
+struct GNUNET_TRANSPORT_TESTING_Handle
{
/**
* Testing library system handle
/**
* head DLL of peers
*/
- struct PeerContext *p_head;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head;
/**
* tail DLL of peers
*/
- struct PeerContext *p_tail;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p_tail;
};
+/**
+ * Initialize the transport testing
+ *
+ * @return transport testing handle
+ */
+struct GNUNET_TRANSPORT_TESTING_Handle *
+GNUNET_TRANSPORT_TESTING_init (void);
+
+
+/**
+ * Clean up the transport testing
+ *
+ * @param tth transport testing handle
+ */
+void
+GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth);
+
+
/**
* Start a peer with the given configuration
*
* @param cb_cls closure for callback
* @return the peer context
*/
-struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+struct GNUNET_TRANSPORT_TESTING_PeerContext *
+GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
const char *cfgname,
int peer_id,
GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd,
- GNUNET_TRANSPORT_TESTING_start_cb start_cb,
+ GNUNET_TRANSPORT_TESTING_StartCallback start_cb,
void *cb_cls);
/**
- * shutdown the given peer
+ * Shutdown the given peer
*
- * @param tth the testing handle
* @param p the peer
*/
void
-GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *pc);
+GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *pc);
/**
- * Restart the given peer
+ * Stops and restarts the given peer, sleeping (!) for 5s in between.
*
* @param p the peer
- * @param cfgname the cfg file used to restart
* @param restart_cb restart callback
* @param cb_cls callback closure
* @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
*/
int
-GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
- const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ GNUNET_TRANSPORT_TESTING_StartCallback restart_cb,
void *cb_cls);
+
/**
- * Connect the given peers and call the callback when both peers report the
- * inbound connection. Remarks: start_peer's notify_connect callback can be called
- * before.
+ * Connect the given peers and call the callback when both peers
+ * report the inbound connection. Remarks: start_peer's notify_connect
+ * callback can be called before.
*
- * @param tth transport testing handle
* @param p1 peer 1
* @param p2 peer 2
* @param cb the callback to call when both peers notified that they are connected
* @return a connect request handle
*/
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext *p2,
- GNUNET_TRANSPORT_TESTING_connect_cb cb,
+GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
+ GNUNET_SCHEDULER_TaskCallback cb,
void *cls);
/**
- * Cancel the request to connect two peers
- * Tou MUST cancel the request if you stop the peers before the peers connected succesfully
- * @param tth testing
+ * Cancel the request to connect two peers. You MUST cancel the
+ * request if you stop the peers before the peers connected
+ * succesfully.
+ *
* @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
+
+/* ********************** high-level process functions *************** */
/**
- * Clean up the transport testing
- * @param tth transport testing handle
+ * Main function of a testcase. Called with the initial setup data
+ * for the test as derived from the source name and the binary name.
+ *
+ * @param cls closure
+ * @param tth initialized testing handle
+ * @param test_plugin name of the plugin (if available)
+ * @param num_peers number of entries in the @a cfg_file array
+ * @param cfg_files array of names of configuration files for the peers
*/
-void
-GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth);
+typedef void
+(*GNUNET_TRANSPORT_TESTING_CheckCallback)(void *cls,
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth,
+ const char *test_plugin,
+ unsigned int num_peers,
+ const char *cfg_files[]);
/**
- * Initialize the transport testing
- * @return transport testing handle
+ * Setup testcase. Calls @a check with the data the test needs.
+ *
+ * @param argv0 binary name (argv[0])
+ * @param filename source file name (__FILE__)
+ * @param num_peers number of peers to start
+ * @param check main function to run
+ * @param check_cls closure for @a check
+ * @return #GNUNET_OK on success
*/
-struct GNUNET_TRANSPORT_TESTING_handle *
-GNUNET_TRANSPORT_TESTING_init (void);
+int
+GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
+ const char *filename,
+ unsigned int num_peers,
+ GNUNET_TRANSPORT_TESTING_CheckCallback check,
+ void *check_cls);
/**
- * Extracts the test filename from an absolute file name and removes the extension
+ * Setup testcase. Calls @a check with the data the test needs.
+ *
+ * @param num_peers number of peers to start
+ * @param check main function to run
+ * @param check_cls closure for @a check
+ * @return #GNUNET_OK on success
+ */
+#define GNUNET_TRANSPORT_TESTING_main(num_peers,check,check_cls) \
+ GNUNET_TRANSPORT_TESTING_main_ (argv[0], __FILE__, num_peers, check, check_cls)
+
+
+/* ********************** low-level filename functions *************** */
+
+
+/**
+ * Extracts the test filename from an absolute file name and removes
+ * the extension.
+ *
* @param file absolute file name
- * @param dest where to store result
+ * @return resulting test name
*/
-void
-GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
- char **dest);
+char *
+GNUNET_TRANSPORT_TESTING_get_test_name (const char *file);
/**
* if existing ".exe"-prefix and adds the peer-number
*
* @param file filename of the test, e.g. argv[0]
- * @param dest where to write the filename
* @param count peer number
+ * @return configuration name to use
*/
-void
+char *
GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
- char **dest,
int count);
* Extracts the plugin anme from an absolute file name and the test name
* @param file absolute file name
* @param test test name
- * @param dest where to store result
+ * @return the plugin name
*/
-void
+char *
GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
- const char *testname,
- char **pluginname);
+ const char *testname);
/**
- * Extracts the filename from an absolute file name and removes the extenstion
+ * Extracts the filename from an absolute file name and removes the
+ * extenstion
+ *
* @param file absolute file name
- * @param dest where to store result
+ * @return the source name
*/
-void
-GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file,
- char **testname);
+char *
+GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
+#endif
/* end of transport_testing.h */