2 This file is part of GNUnet
3 (C) 2012 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 2, 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 set/gnunet-set.c
23 * @brief profiling tool for the set service
24 * @author Florian Dold
27 #include "gnunet_common.h"
28 #include "gnunet_applications.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_stream_lib.h"
33 static struct GNUNET_PeerIdentity local_id;
35 static struct GNUNET_STREAM_ListenSocket *listen_socket;
37 static struct GNUNET_STREAM_Socket *s1;
42 stream_data_processor (void *cls,
43 enum GNUNET_STREAM_Status status,
52 struct GNUNET_STREAM_Socket *socket,
54 GNUNET_PeerIdentity *initiator)
58 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "socket listen failed\n");
62 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "socket listen succesful\n");
63 GNUNET_assert (NULL != socket);
64 GNUNET_assert (0 == memcmp (initiator, &local_id, sizeof (*initiator)));
65 GNUNET_STREAM_read (socket, GNUNET_TIME_UNIT_FOREVER_REL,
66 stream_data_processor, NULL);
71 open_cb (void *cls, struct GNUNET_STREAM_Socket *socket)
76 * Main function that will be run.
79 * @param args remaining command-line arguments
80 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
81 * @param cfg configuration
84 run (void *cls, char *const *args,
86 const struct GNUNET_CONFIGURATION_Handle *cfg)
89 GNUNET_CRYPTO_get_host_identity (cfg, &local_id);
91 listen_socket = GNUNET_STREAM_listen (cfg,
92 GNUNET_APPLICATION_TYPE_SET,
97 s1 = GNUNET_STREAM_open (cfg,
99 GNUNET_APPLICATION_TYPE_SET,
108 main (int argc, char **argv)
110 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
111 GNUNET_GETOPT_OPTION_END
113 GNUNET_PROGRAM_run (argc, argv, "gnunet-set",
115 options, &run, NULL);