/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011 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
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., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file transport/transport_api_blacklisting.c
- * @brief test for the blacklisting API
- * stage 0: init
- * stage 1: connect peers and stop
- * stage 2: blacklist whole peer and connect
- * stage 3: blacklist tcp and try connect
+ * @brief test for the blacklisting with blacklistings defined in cfg
+ *
+ * this file contains multiple tests:
+ *
+ * test_transport_blacklisting_no_bl:
+ * no blacklisting entries
+ * peers are expected to connect
+ * test_transport_blacklisting_outbound_bl_full:
+ * both peers contain bl entries for full peer
+ * test is expected to not connect
+ * test_transport_blacklisting_outbound_bl_plugin:
+ * both peers contain bl entries for plugin
+ * test is expected to not connect
+ * test_transport_blacklisting_inbound_bl_plugin:
+ * peer 1 contains no bl entries
+ * peer 2 contain bl entries for full peer
+ * test is expected to not connect
+ * test_transport_blacklisting_inbound_bl_full:
+ * peer 1 contains no bl entries
+ * peer 2 contain bl entries for plugin
+ * test is expected to not connect
+ * test_transport_blacklisting_multiple_plugins:
+ * both peers contain bl entries for plugin
+ * test is expected to connect with not bl'ed plugin
*
* @author Matthias Wachs
*
struct PeerContext *p2;
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
struct GNUNET_TRANSPORT_TESTING_handle *tth;
static int ok;
static int connected;
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
+static struct GNUNET_SCHEDULER_Task * die_task;
-static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+static struct GNUNET_SCHEDULER_Task * timeout_task;
-static GNUNET_SCHEDULER_TaskIdentifier stage_task;
+static struct GNUNET_SCHEDULER_Task * stage_task;
#if VERBOSE
#define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
#define OKPP do { ok++; } while (0)
#endif
+
static void
-run_stage(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+run_stage(void *cls);
+
static void
-end(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+end (void *cls)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Stopping\n");
- if (die_task != GNUNET_SCHEDULER_NO_TASK )
+ if (die_task != NULL )
{
GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_NO_TASK;
+ die_task = NULL;
}
- if (timeout_task != GNUNET_SCHEDULER_NO_TASK )
+ if (timeout_task != NULL )
{
GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ timeout_task = NULL;
}
- if (stage_task != GNUNET_SCHEDULER_NO_TASK )
+ if (stage_task != NULL )
{
GNUNET_SCHEDULER_cancel (stage_task);
- stage_task = GNUNET_SCHEDULER_NO_TASK;
+ stage_task = NULL;
}
if (cc != NULL )
}
}
+
static void
-end_badly(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+end_badly (void *cls)
{
- die_task = GNUNET_SCHEDULER_NO_TASK;
+ die_task = NULL;
- if (timeout_task != GNUNET_SCHEDULER_NO_TASK )
+ if (timeout_task != NULL )
{
GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ timeout_task = NULL;
}
- if (stage_task != GNUNET_SCHEDULER_NO_TASK )
+ if (stage_task != NULL )
{
GNUNET_SCHEDULER_cancel (stage_task);
- stage_task = GNUNET_SCHEDULER_NO_TASK;
+ stage_task = NULL;
}
if (cc != NULL )
stage_task = GNUNET_SCHEDULER_add_now (&run_stage, NULL );
}
+
static void
-connect_timeout(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+connect_timeout(void *cls)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Peers not connected, next stage\n");
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
- stage_task = GNUNET_SCHEDULER_add_now (&run_stage, NULL );
+ timeout_task = NULL;
+ stage_task = GNUNET_SCHEDULER_add_now (&run_stage, NULL);
}
+
static int started;
-void
+
+static void
start_cb(struct PeerContext *p, void *cls)
{
return GNUNET_OK;
}
+
static void
-run_stage(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+run_stage (void *cls)
{
- stage_task = GNUNET_SCHEDULER_NO_TASK;
- if (GNUNET_SCHEDULER_NO_TASK != die_task)
+ stage_task = NULL;
+ if (NULL != die_task)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL );
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Running stage %u\n", stage);