2 This file is part of GNUnet.
3 (C) 2009 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 src/transport/gnunet-transport.c
23 * @brief Tool to help configure the transports.
24 * @author Christian Grothoff
26 * This utility can be used to test if a transport mechanism for
27 * GNUnet is properly configured.
31 #include "gnunet_program_lib.h"
32 #include "gnunet_protocols.h"
33 #include "gnunet_transport_service.h"
37 static struct GNUNET_TRANSPORT_Handle *handle;
40 do_disconnect (void *cls,
41 const struct GNUNET_SCHEDULER_TaskContext *tc)
43 GNUNET_TRANSPORT_disconnect (handle);
48 * Main function that will be run by the scheduler.
51 * @param args remaining command-line arguments
52 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
53 * @param cfg configuration
56 run (void *cls, char *const *args, const char *cfgfile,
57 const struct GNUNET_CONFIGURATION_Handle *cfg)
59 struct GNUNET_PeerIdentity pid;
62 handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL,
65 GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey))
68 _("Failed to parse peer identity `%s'\n"),
70 GNUNET_TRANSPORT_disconnect (handle);
73 GNUNET_TRANSPORT_try_connect (handle, &pid);
74 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
82 main (int argc, char *const *argv)
84 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
85 {'C', "connect", "PEER",
86 gettext_noop ("try to connect to the given peer"),
87 1, &GNUNET_GETOPT_set_string, &cpid},
88 GNUNET_GETOPT_OPTION_END
91 GNUNET_PROGRAM_run (argc, argv, "gnunet-transport",
92 gettext_noop ("Direct access to transport service."),
93 options, &run, NULL)) ? 0 : 1;
97 /* end of gnunet-transport.c */