2 This file is part of GNUnet.
3 (C) 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 core/gnunet-transport-list-connections.c
24 * @brief Print all known address information about other peers.
26 * Lists all peers and connections that the transport service is
27 * aware of. Pretty prints addresses, peer id's, and whether
28 * or not the _address_ is connected. Note that these are not
29 * core level connections, only transport level connections.
31 * @author Nathan Evans
34 #include "gnunet_crypto_lib.h"
35 #include "gnunet_configuration_lib.h"
36 #include "gnunet_getopt_lib.h"
37 #include "gnunet_transport_service.h"
38 #include "gnunet_program_lib.h"
41 static int no_resolve;
44 static unsigned int connection_count;
47 static const struct GNUNET_CONFIGURATION_Handle *cfg;
50 * Function to call with a human-readable format of an address
53 * @param address NULL on error, otherwise 0-terminated printable UTF-8 string
56 process_address (void *cls,
63 fprintf(stdout, "%s\n", address);
68 * Main function that will be run by the scheduler.
71 * @param args remaining command-line arguments
72 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
73 * @param c configuration
79 const struct GNUNET_CONFIGURATION_Handle *c)
86 _("Invalid command line argument `%s'\n"),
91 GNUNET_TRANSPORT_address_iterate (cfg,
92 GNUNET_TIME_UNIT_MINUTES,
93 &process_address, NULL);
98 * The main function to obtain peer information.
100 * @param argc number of arguments from the command line
101 * @param argv command line arguments
102 * @return 0 ok, 1 on error
105 main (int argc, char *const *argv)
107 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
108 {'n', "numeric", NULL,
109 gettext_noop ("don't resolve host names"),
110 0, &GNUNET_GETOPT_set_one, &no_resolve},
111 GNUNET_GETOPT_OPTION_END
114 GNUNET_PROGRAM_run (argc,
116 "gnunet-list-connections",
117 gettext_noop ("Print information about connected peers."),
118 options, &run, NULL)) ? 0 : 1;
121 /* end of gnunet-transport-list-connections.c */