GNUnet  0.10.x
Functions | Variables
gnunet-nse.c File Reference

Program to display network size estimates from the NSE service. More...

#include "platform.h"
#include "gnunet_nse_service.h"
Include dependency graph for gnunet-nse.c:

Go to the source code of this file.

Functions

static void do_shutdown (void *cls)
 Task to shutdown and clean up all state. More...
 
static void handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev)
 Callback to call when network size estimate is updated. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Actual main function that runs the emulation. More...
 
int main (int argc, char *const *argv)
 Main function. More...
 

Variables

static struct GNUNET_NSE_Handlense
 The handle to the NSE service. More...
 
static int status
 The program status; 0 for success. More...
 

Detailed Description

Program to display network size estimates from the NSE service.

Author
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file gnunet-nse.c.

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Task to shutdown and clean up all state.

Parameters
clsNULL

Definition at line 47 of file gnunet-nse.c.

References GNUNET_NSE_disconnect().

Referenced by run().

48 {
49  (void)cls;
50  if (NULL != nse)
51  {
53  nse = NULL;
54  }
55 }
static struct GNUNET_NSE_Handle * nse
The handle to the NSE service.
Definition: gnunet-nse.c:33
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
Definition: nse_api.c:192
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_estimate()

static void handle_estimate ( void *  cls,
struct GNUNET_TIME_Absolute  timestamp,
double  estimate,
double  std_dev 
)
static

Callback to call when network size estimate is updated.

Parameters
clsNULL
timestampserver timestamp
estimatethe value of the current network size estimate
std_devstandard deviation (rounded down to nearest integer) of the size estimation values seen

Definition at line 68 of file gnunet-nse.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_NSE_log_estimate_to_n, and status.

Referenced by run().

72 {
73  (void)cls;
74  status = 0;
75  fprintf(stdout,
76  "%llu %f %f %f\n",
77  (unsigned long long)timestamp.abs_value_us,
79  estimate,
80  std_dev);
81 }
uint64_t abs_value_us
The actual value.
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:38
#define GNUNET_NSE_log_estimate_to_n(loge)
Convert the logarithmic estimated returned to the 'GNUNET_NSE_Callback' into an absolute estimate in ...
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Actual main function that runs the emulation.

Parameters
clsunused
argsremaining args, unused
cfgfilename of the configuration
cfgconfiguration handle

Definition at line 93 of file gnunet-nse.c.

References do_shutdown(), GNUNET_NSE_connect(), GNUNET_SCHEDULER_add_shutdown(), and handle_estimate().

Referenced by main().

97 {
98  (void)cls;
99  (void)args;
100  (void)cfgfile;
101  nse = GNUNET_NSE_connect(cfg, &handle_estimate, NULL);
103 }
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
struct GNUNET_NSE_Handle * GNUNET_NSE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
Connect to the network size estimation service.
Definition: nse_api.c:164
static struct GNUNET_NSE_Handle * nse
The handle to the NSE service.
Definition: gnunet-nse.c:33
static void do_shutdown(void *cls)
Task to shutdown and clean up all state.
Definition: gnunet-nse.c:47
static void handle_estimate(void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev)
Callback to call when network size estimate is updated.
Definition: gnunet-nse.c:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Main function.

Returns
0 on success

Definition at line 112 of file gnunet-nse.c.

References gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_PROGRAM_run(), run(), and status.

113 {
114  static struct GNUNET_GETOPT_CommandLineOption options[] = {
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 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Actual main function that runs the emulation.
Definition: gnunet-nse.c:93
Definition of a command line option.
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:38
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ nse

struct GNUNET_NSE_Handle* nse
static

The handle to the NSE service.

Definition at line 33 of file gnunet-nse.c.

◆ status

int status
static

The program status; 0 for success.

Definition at line 38 of file gnunet-nse.c.

Referenced by handle_estimate(), and main().