2 This file is part of GNUnet
3 (C) 2009 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 include/gnunet_statistics_service.h
23 * @brief API to create, modify and access statistics about
24 * the operation of GNUnet; all statistical values
25 * must be of type "unsigned long long".
26 * @author Christian Grothoff
29 #ifndef GNUNET_STATISTICS_SERVICE_H
30 #define GNUNET_STATISTICS_SERVICE_H
35 #if 0 /* keep Emacsens' auto-indent happy */
40 #include "gnunet_common.h"
41 #include "gnunet_configuration_lib.h"
42 #include "gnunet_scheduler_lib.h"
45 * Version of the statistics API.
47 #define GNUNET_STATISTICS_VERSION 0x00000000
50 * Opaque handle for the statistics service.
52 struct GNUNET_STATISTICS_Handle;
55 * Callback function to process statistic values.
58 * @param subsystem name of subsystem that created the statistic
59 * @param name the name of the datum
60 * @param value the current value
61 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
62 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
64 typedef int (*GNUNET_STATISTICS_Iterator) (void *cls,
65 const char *subsystem,
67 unsigned long long value,
71 * Get handle for the statistics service.
73 * @param sched scheduler to use
74 * @param subsystem name of subsystem using the service
75 * @param cfg services configuration in use
76 * @return handle to use
78 struct GNUNET_STATISTICS_Handle
79 *GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched,
80 const char *subsystem,
81 struct GNUNET_CONFIGURATION_Handle *cfg);
85 * Destroy a handle (free all state associated with
88 void GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *handle);
92 * Continuation called by the "get_all" and "get" functions.
95 * @param success GNUNET_OK if statistics were
96 * successfully obtained, GNUNET_SYSERR if not.
98 typedef void (*GNUNET_STATISTICS_Callback) (void *cls, int success);
101 * Get statistic from the peer.
103 * @param handle identification of the statistics service
104 * @param subsystem limit to the specified subsystem, NULL for our subsystem
105 * @param name name of the statistic value, NULL for all values
106 * @param timeout after how long should we give up (and call
107 * notify with buf NULL and size 0)?
108 * @param cont continuation to call when done (can be NULL)
109 * @param proc function to call on each value
110 * @param cls closure for proc and cont
113 GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle,
114 const char *subsystem,
116 struct GNUNET_TIME_Relative timeout,
117 GNUNET_STATISTICS_Callback cont,
118 GNUNET_STATISTICS_Iterator proc, void *cls);
121 * Set statistic value for the peer. Will always use our
122 * subsystem (the argument used when "handle" was created).
124 * @param handle identification of the statistics service
125 * @param name name of the statistic value
126 * @param value new value to set
127 * @param make_persistent should the value be kept across restarts?
130 GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
132 unsigned long long value, int make_persistent);
135 * Set statistic value for the peer. Will always use our
136 * subsystem (the argument used when "handle" was created).
138 * @param handle identification of the statistics service
139 * @param name name of the statistic value
140 * @param delta change in value (added to existing value)
141 * @param make_persistent should the value be kept across restarts?
144 GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
146 long long delta, int make_persistent);
150 #if 0 /* keep Emacsens' auto-indent happy */