aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport-list-connections.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-26 21:08:12 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-26 21:08:12 +0000
commit0115376751f596cfe1865df854a28b797afb6395 (patch)
tree036373b47cb025d79aa0fba6efdb757e6ccd0877 /src/transport/gnunet-transport-list-connections.c
parent8ff0618cd174a9270d9bad688bdc4da45984067b (diff)
downloadgnunet-0115376751f596cfe1865df854a28b797afb6395.tar.gz
gnunet-0115376751f596cfe1865df854a28b797afb6395.zip
integrate gnunet-transport-list-connections with gnunet-transport
Diffstat (limited to 'src/transport/gnunet-transport-list-connections.c')
-rw-r--r--src/transport/gnunet-transport-list-connections.c123
1 files changed, 0 insertions, 123 deletions
diff --git a/src/transport/gnunet-transport-list-connections.c b/src/transport/gnunet-transport-list-connections.c
deleted file mode 100644
index 64b67dcd4..000000000
--- a/src/transport/gnunet-transport-list-connections.c
+++ /dev/null
@@ -1,123 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19*/
20
21/**
22 * @file transport/gnunet-transport-list-connections.c
23 *
24 * @brief Print all known address information about other peers.
25 *
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.
30 *
31 * @author Nathan Evans
32 */
33#include "platform.h"
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"
39
40#define VERBOSE 0
41static int no_resolve;
42
43#if VERBOSE
44static unsigned int connection_count;
45#endif
46
47static const struct GNUNET_CONFIGURATION_Handle *cfg;
48
49/**
50 * Function to call with a human-readable format of an address
51 *
52 * @param cls closure
53 * @param address NULL on error, otherwise 0-terminated printable UTF-8 string
54 */
55static void
56process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
57 const char *transport, const void *addr, size_t addrlen)
58{
59#if VERBOSE
60 connection_count++;
61#endif
62 if ((peer != NULL) || (transport != NULL) ||
63 ((addr != NULL) && (addrlen > 0)))
64 fprintf (stdout, "Peer `%s' plugin: `%s' address `%s'\n",
65 (peer != NULL) ? GNUNET_i2s (peer) : "<unknown>",
66 (transport != NULL) ? transport : "<unknown>", ((addr != NULL) &&
67 (addrlen > 0) &&
68 (transport !=
69 NULL)) ?
70 "how do i resolve the name without transport service?" :
71 "<unknown>");
72}
73
74
75/**
76 * Main function that will be run by the scheduler.
77 *
78 * @param cls closure
79 * @param args remaining command-line arguments
80 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
81 * @param c configuration
82 */
83static void
84run (void *cls, char *const *args, const char *cfgfile,
85 const struct GNUNET_CONFIGURATION_Handle *c)
86{
87
88 cfg = c;
89 if (args[0] != NULL)
90 {
91 fprintf (stderr, _("Invalid command line argument `%s'\n"), args[0]);
92 return;
93 }
94
95 GNUNET_TRANSPORT_address_iterate (cfg, GNUNET_TIME_UNIT_MINUTES,
96 &process_address, NULL);
97}
98
99
100/**
101 * The main function to obtain peer information.
102 *
103 * @param argc number of arguments from the command line
104 * @param argv command line arguments
105 * @return 0 ok, 1 on error
106 */
107int
108main (int argc, char *const *argv)
109{
110 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
111 {'n', "numeric", NULL,
112 gettext_noop ("don't resolve host names"),
113 0, &GNUNET_GETOPT_set_one, &no_resolve},
114 GNUNET_GETOPT_OPTION_END
115 };
116 return (GNUNET_OK ==
117 GNUNET_PROGRAM_run (argc, argv, "gnunet-list-connections",
118 gettext_noop
119 ("Print information about connected peers."),
120 options, &run, NULL)) ? 0 : 1;
121}
122
123/* end of gnunet-transport-list-connections.c */