struct GNUNET_TRANSPORT_TESTING_handle *tth;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
/*
static struct GNUNET_TRANSPORT_TESTING_handle *tth;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static int test_connected;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc1;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc2;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc1;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc2;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
*/
static char bitmap[TOTAL_MSGS / 8];
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
/*
* END Testcase specific declarations
static int p2_connected;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
uint32_t max_bps_p1;
uint32_t max_bps_p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
/*
* Testcase specific declarations
struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
struct GNUNET_TRANSPORT_TESTING_handle *tth;
static struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
struct GNUNET_TRANSPORT_TESTING_handle *tth;
/*
This file is part of GNUnet.
- Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
}
-static struct ConnectingContext *
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1, struct PeerContext *p2)
+ struct PeerContext *p1,
+ struct PeerContext *p2)
{
GNUNET_assert (tth != NULL);
- struct ConnectingContext *cc = tth->cc_head;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head;
while (cc != NULL)
{
static void
-notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
char *p2_s;
GNUNET_free (p2_s);
/* Find ConnectingContext */
- struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2);
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = find_connecting_context (p->tth, p, p2);
if (cc == NULL)
return;
static void
-notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
static void
-notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+notify_receive (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cls;
static void
-get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message)
+get_hello (void *cb_cls,
+ const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cb_cls;
struct GNUNET_PeerIdentity hello_id;
static void
-try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+try_connect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct ConnectingContext *cc = cls;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
struct PeerContext *p1 = cc->p1;
struct PeerContext *p2 = cc->p2;
* @param cls callback cls
* @return a connect request handle
*/
-GNUNET_TRANSPORT_TESTING_ConnectRequest
+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,
void *cls)
{
- GNUNET_assert (tth != NULL);
-
- struct ConnectingContext *cc =
- GNUNET_new (struct ConnectingContext);
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
+ GNUNET_assert (tth != NULL);
GNUNET_assert (p1 != NULL);
GNUNET_assert (p2 != NULL);
cc->p1 = p1;
cc->th_p2 = p2->th;
GNUNET_assert (cc->th_p1 != NULL);
GNUNET_assert (cc->th_p2 != NULL);
- GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc);
+ GNUNET_CONTAINER_DLL_insert (tth->cc_head,
+ tth->cc_tail,
+ cc);
cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"New connect request %p\n",
* Tou MUST cancel the request if you stop the peers before the peers connected succesfully
*
* @param tth transport testing handle
- * @param ccr a connect request handle
+ * @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct
- GNUNET_TRANSPORT_TESTING_handle
- *tth,
- GNUNET_TRANSPORT_TESTING_ConnectRequest
- ccr)
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
{
- struct ConnectingContext *cc = ccr;
-
GNUNET_assert (tth != NULL);
LOG (GNUNET_ERROR_TYPE_DEBUG,
void
GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
{
- struct ConnectingContext *cc = tth->cc_head;
- struct ConnectingContext *ct = NULL;
+ 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;
tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle);
/* Init testing the testing lib */
- tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL,
- NULL, NULL);
+ tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
+ NULL,
+ NULL,
+ NULL);
if (NULL == tth->tl_system)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing library!\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to initialize testing library!\n"));
GNUNET_free (tth);
return NULL;
}
* @param dest where to store result
*/
void
-GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest)
+GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
+ char **dest)
{
char *filename = extract_filename (file);
char *backup = filename;
* @param dest where to store result
*/
void
-GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file, char **dest)
+GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file,
+ char **dest)
{
char *src = extract_filename (file);
char *split;
*/
void
GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
- const char *test, char **dest)
+ const char *test,
+ char **dest)
{
char *filename;
char *dotexe;
* @param count peer number
*/
void
-GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **dest,
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
+ char **dest,
int count)
{
char *filename = extract_filename (file);
/*
This file is part of GNUnet.
- Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
#include "gnunet_testing_lib.h"
-#define GNUNET_TRANSPORT_TESTING_ConnectRequest void *
+struct GNUNET_TRANSPORT_TESTING_ConnectRequest;
/**
* 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_start_cb) (struct PeerContext * p,
- void *cls);
+typedef void
+(*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext *p,
+ void *cls);
/**
* 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);
+typedef void
+(*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext *p1,
+ struct PeerContext *p2,
+ void *cls);
/**
};
-struct ConnectingContext
+struct GNUNET_TRANSPORT_TESTING_ConnectRequest
{
- struct ConnectingContext *next;
- struct ConnectingContext *prev;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
struct PeerContext *p1;
struct PeerContext *p2;
- struct GNUNET_SCHEDULER_Task * tct;
+ struct GNUNET_SCHEDULER_Task *tct;
GNUNET_TRANSPORT_TESTING_connect_cb cb;
void *cb_cls;
struct GNUNET_TRANSPORT_Handle *th_p1;
/**
* head DLL of connect contexts
*/
- struct ConnectingContext *cc_head;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_head;
/**
* head DLL of connect contexts
*/
- struct ConnectingContext *cc_tail;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail;
/**
* head DLL of peers
/**
-* Start a peer with the given configuration
-* @param tth the testing handle
-* @param cfgname configuration file
-* @param peer_id the peer_id
-* @param rec receive callback
-* @param nc connect callback
-* @param nd disconnect callback
-* @param start_cb start callback
-* @param cb_cls closure for callback
-* @return the peer context
-*/
+ * Start a peer with the given configuration
+ *
+ * @param tth the testing handle
+ * @param cfgname configuration file
+ * @param peer_id the peer_id
+ * @param rec receive callback
+ * @param nc connect callback
+ * @param nd disconnect callback
+ * @param start_cb start callback
+ * @param cb_cls closure for callback
+ * @return the peer context
+ */
struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
- *tth, const char *cfgname, int peer_id,
+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,
/**
* 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);
/**
-* Restart the given peer
-* @param tth testing handle
-* @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
-*/
+ * Restart the given peer
+ *
+ * @param tth testing handle
+ * @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 GNUNET_TRANSPORT_TESTING_handle
- *tth, struct PeerContext *p,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+ struct PeerContext *p,
const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb
- restart_cb, void *cb_cls);
+ GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
+ void *cb_cls);
+
/**
* Connect the given peers and call the callback when both peers report the
* @param cls callback cls
* @return a connect request handle
*/
-GNUNET_TRANSPORT_TESTING_ConnectRequest
+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,
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
- * @param ccr a connect request handle
+ * @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct
- GNUNET_TRANSPORT_TESTING_handle
- *tth,
- GNUNET_TRANSPORT_TESTING_ConnectRequest
- ccr);
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
/**
* Clean up the transport testing
* @return transport testing handle
*/
struct GNUNET_TRANSPORT_TESTING_handle *
-GNUNET_TRANSPORT_TESTING_init ();
+GNUNET_TRANSPORT_TESTING_init (void);
/*
* Some utility functions
* @param dest where to store result
*/
void
-GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest);
+GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
+ char **dest);
/**
* This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
* @param count peer number
*/
void
-GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **dest,
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
+ char **dest,
int count);