2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/transport_api_blacklisting.c
23 * @brief test for the blacklisting API
24 * @author Matthias Wachs
28 #include "gnunet_common.h"
29 #include "gnunet_hello_lib.h"
30 #include "gnunet_getopt_lib.h"
31 #include "gnunet_os_lib.h"
32 #include "gnunet_program_lib.h"
33 #include "gnunet_scheduler_lib.h"
34 #include "gnunet_transport_service.h"
35 #include "transport.h"
36 #include "transport-testing.h"
38 #define VERBOSE GNUNET_EXTRA_LOGGING
39 #define VERBOSE_ARM GNUNET_EXTRA_LOGGING
41 #define START_ARM GNUNET_YES
44 * How long until we give up on transmitting the message?
46 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
49 * How long until we give up on transmitting the message?
51 #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
57 struct GNUNET_TRANSPORT_Blacklist * blacklist;
59 static GNUNET_SCHEDULER_TaskIdentifier die_task;
62 #define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
64 #define OKPP do { ok++; } while (0)
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping\n");
73 if (die_task != GNUNET_SCHEDULER_NO_TASK)
74 GNUNET_SCHEDULER_cancel (die_task);
80 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
82 die_task = GNUNET_SCHEDULER_NO_TASK;
84 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail!\n");
90 int blacklist_cb (void *cls,
92 GNUNET_PeerIdentity * pid)
98 run (void *cls, char *const *args, const char *cfgfile,
99 const struct GNUNET_CONFIGURATION_Handle *cfg)
101 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
103 blacklist = GNUNET_TRANSPORT_blacklist (cfg,
107 GNUNET_assert (blacklist != NULL);
109 GNUNET_TRANSPORT_blacklist_cancel (blacklist);
118 static char *const argv[] = { "test-transport-api-blacklisting",
120 "test_transport_api_data.conf",
126 static struct GNUNET_GETOPT_CommandLineOption options[] = {
127 GNUNET_GETOPT_OPTION_END
131 setTransportOptions ("test_transport_api_data.conf");
135 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-transport-api-blacklisting",
136 "nohelp", options, &run, &ok);
142 main (int argc, char *argv[])
146 GNUNET_log_setup ("test-transport-api-blacklisting",
159 /* end of transport_api_blacklisting.c */