aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-set-bug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/set/gnunet-set-bug.c')
-rw-r--r--src/set/gnunet-set-bug.c142
1 files changed, 0 insertions, 142 deletions
diff --git a/src/set/gnunet-set-bug.c b/src/set/gnunet-set-bug.c
deleted file mode 100644
index 112def7d7..000000000
--- a/src/set/gnunet-set-bug.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/*
2 This file is part of GNUnet
3 (C) 2012 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 2, 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 set/gnunet-set.c
23 * @brief profiling tool for the set service
24 * @author Florian Dold
25 */
26#include "platform.h"
27#include "gnunet_common.h"
28#include "gnunet_applications.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_stream_lib.h"
31
32
33static struct GNUNET_PeerIdentity local_id;
34
35static struct GNUNET_CONFIGURATION_Handle *cfg;
36
37static struct GNUNET_STREAM_ListenSocket *listen_socket;
38
39static struct GNUNET_STREAM_Socket *s1;
40
41static struct GNUNET_STREAM_Socket *s2;
42
43static void
44do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
45{
46 if (NULL != s2)
47 GNUNET_STREAM_close (s2);
48 GNUNET_STREAM_close (s1);
49 GNUNET_STREAM_listen_close (listen_socket);
50 GNUNET_CONFIGURATION_destroy (cfg);
51}
52
53static size_t
54stream_data_processor (void *cls,
55 enum GNUNET_STREAM_Status status,
56 const void *data,
57 size_t size)
58{
59 return size;
60}
61
62static int
63listen_cb (void *cls,
64 struct GNUNET_STREAM_Socket *socket,
65 const struct
66 GNUNET_PeerIdentity *initiator)
67{
68 if (NULL == (s2 = socket))
69 {
70 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "socket listen failed\n");
71 return GNUNET_NO;
72 }
73
74 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "socket listen succesful\n");
75 GNUNET_assert (NULL != socket);
76 GNUNET_assert (0 == memcmp (initiator, &local_id, sizeof (*initiator)));
77 GNUNET_STREAM_read (socket, GNUNET_TIME_UNIT_FOREVER_REL,
78 &stream_data_processor, NULL);
79 return GNUNET_YES;
80}
81
82static void
83open_cb (void *cls, struct GNUNET_STREAM_Socket *socket)
84{
85
86}
87
88static void
89stream_connect (void)
90{
91 s1 = GNUNET_STREAM_open (cfg,
92 &local_id,
93 GNUNET_APPLICATION_TYPE_SET,
94 &open_cb,
95 NULL,
96 GNUNET_STREAM_OPTION_END);
97}
98
99/**
100 * Main function that will be run.
101 *
102 * @param cls closure
103 * @param args remaining command-line arguments
104 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
105 * @param cfg configuration
106 */
107static void
108run (void *cls, char *const *args,
109 const char *cfgfile,
110 const struct GNUNET_CONFIGURATION_Handle *cfg2)
111{
112
113 cfg = GNUNET_CONFIGURATION_dup (cfg2);
114 GNUNET_CRYPTO_get_host_identity (cfg, &local_id);
115
116 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "I am Peer %s\n", GNUNET_h2s (&local_id.hashPubKey));
117
118 listen_socket = GNUNET_STREAM_listen (cfg,
119 GNUNET_APPLICATION_TYPE_SET,
120 &listen_cb,
121 NULL,
122 GNUNET_STREAM_OPTION_SIGNAL_LISTEN_SUCCESS,
123 &stream_connect,
124 GNUNET_STREAM_OPTION_END);
125 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
126 &do_shutdown, NULL);
127}
128
129
130
131int
132main (int argc, char **argv)
133{
134 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
135 GNUNET_GETOPT_OPTION_END
136 };
137 GNUNET_PROGRAM_run (argc, argv, "gnunet-set",
138 "help",
139 options, &run, NULL);
140 return 0;
141}
142