aboutsummaryrefslogtreecommitdiff
path: root/src/nse/gnunet-nse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nse/gnunet-nse.c')
-rw-r--r--src/nse/gnunet-nse.c130
1 files changed, 0 insertions, 130 deletions
diff --git a/src/nse/gnunet-nse.c b/src/nse/gnunet-nse.c
deleted file mode 100644
index edb73c0fc..000000000
--- a/src/nse/gnunet-nse.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2008--2014, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file nse/gnunet-nse.c
23 * @brief Program to display network size estimates from the NSE service
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */
26
27#include "platform.h"
28#include "gnunet_nse_service.h"
29
30/**
31 * The handle to the NSE service
32 */
33static struct GNUNET_NSE_Handle *nse;
34
35/**
36 * The program status; 0 for success.
37 */
38static int status;
39
40
41/**
42 * Task to shutdown and clean up all state
43 *
44 * @param cls NULL
45 */
46static void
47do_shutdown (void *cls)
48{
49 (void) cls;
50 if (NULL != nse)
51 {
52 GNUNET_NSE_disconnect (nse);
53 nse = NULL;
54 }
55}
56
57
58/**
59 * Callback to call when network size estimate is updated.
60 *
61 * @param cls NULL
62 * @param timestamp server timestamp
63 * @param estimate the value of the current network size estimate
64 * @param std_dev standard deviation (rounded down to nearest integer)
65 * of the size estimation values seen
66 */
67static void
68handle_estimate (void *cls,
69 struct GNUNET_TIME_Absolute timestamp,
70 double estimate,
71 double std_dev)
72{
73 (void) cls;
74 status = 0;
75 fprintf (stdout,
76 "%llu %f %f %f\n",
77 (unsigned long long) timestamp.abs_value_us,
78 GNUNET_NSE_log_estimate_to_n (estimate),
79 estimate,
80 std_dev);
81}
82
83
84/**
85 * Actual main function that runs the emulation.
86 *
87 * @param cls unused
88 * @param args remaining args, unused
89 * @param cfgfile name of the configuration
90 * @param cfg configuration handle
91 */
92static void
93run (void *cls,
94 char *const *args,
95 const char *cfgfile,
96 const struct GNUNET_CONFIGURATION_Handle *cfg)
97{
98 (void) cls;
99 (void) args;
100 (void) cfgfile;
101 nse = GNUNET_NSE_connect (cfg, &handle_estimate, NULL);
102 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
103}
104
105
106/**
107 * Main function.
108 *
109 * @return 0 on success
110 */
111int
112main (int argc, char *const *argv)
113{
114 static struct GNUNET_GETOPT_CommandLineOption options[] = {
115 GNUNET_GETOPT_OPTION_END
116 };
117
118 status = 1;
119 if (GNUNET_OK !=
120 GNUNET_PROGRAM_run (argc,
121 argv,
122 "gnunet-nse",
123 gettext_noop (
124 "Show network size estimates from NSE service."),
125 options,
126 &run,
127 NULL))
128 return 2;
129 return status;
130}