paragraph for gnunet devs that don't know how to use the web
[oweals/gnunet.git] / src / statistics / statistics.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2001-2014 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
19 /**
20  * @author Christian Grothoff
21  * @file statistics/statistics.h
22  */
23 #ifndef STATISTICS_H
24 #define STATISTICS_H
25
26 #include "gnunet_common.h"
27
28
29 GNUNET_NETWORK_STRUCT_BEGIN
30
31 /**
32  * Statistics message. Contains how long the system is up
33  * and one value.
34  *
35  * The struct is be followed by the service name and
36  * name of the statistic, both 0-terminated.
37  */
38 struct GNUNET_STATISTICS_ReplyMessage
39 {
40   /**
41    * Type:  GNUNET_MESSAGE_TYPE_STATISTICS_VALUE
42    */
43   struct GNUNET_MessageHeader header;
44
45   /**
46    * Unique numerical identifier for the value (will
47    * not change during the same client-session).  Highest
48    * bit will be set for persistent values (see
49    * #GNUNET_STATISTICS_PERSIST_BIT).
50    */
51   uint32_t uid GNUNET_PACKED;
52
53   /**
54    * The value.
55    */
56   uint64_t value GNUNET_PACKED;
57
58 };
59
60 /**
61  * Flag for the `struct GNUNET_STATISTICS_ReplyMessage` UID only.
62  * Note that other messages use #GNUNET_STATISTICS_SETFLAG_PERSISTENT.
63  */
64 #define GNUNET_STATISTICS_PERSIST_BIT ((uint32_t) (1LLU<<31))
65
66 /**
67  * The value being set is an absolute change.
68  */
69 #define GNUNET_STATISTICS_SETFLAG_ABSOLUTE 0
70
71 /**
72  * The value being set is a relative change.
73  */
74 #define GNUNET_STATISTICS_SETFLAG_RELATIVE 1
75
76 /**
77  * The value being set is to be persistent (note that
78  * this bit can be combined with #GNUNET_STATISTICS_SETFLAG_RELATIVE).
79  * This value must not be used for the `uid` member of
80  * `struct GNUNET_STATISTICS_ReplyMessage`!
81  */
82 #define GNUNET_STATISTICS_SETFLAG_PERSISTENT 2
83
84
85 /**
86  * Message to set a statistic.  Followed
87  * by the subsystem name and the name of
88  * the statistic (each 0-terminated).
89  */
90 struct GNUNET_STATISTICS_SetMessage
91 {
92   /**
93    * Type: #GNUNET_MESSAGE_TYPE_STATISTICS_SET
94    */
95   struct GNUNET_MessageHeader header;
96
97   /**
98    * 0 for absolute value, 1 for relative value; 2 to make persistent
99    * (see GNUNET_STATISTICS_SETFLAG_*).
100    */
101   uint32_t flags GNUNET_PACKED;
102
103   /**
104    * Value. Note that if this is a relative value, it will
105    * be signed even though the type given here is unsigned.
106    */
107   uint64_t value GNUNET_PACKED;
108
109 };
110
111
112 /**
113  * Message transmitted if a watched value changes.
114  */
115 struct GNUNET_STATISTICS_WatchValueMessage
116 {
117   /**
118    * Type: #GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE
119    */
120   struct GNUNET_MessageHeader header;
121
122   /**
123    * 0 for absolute value, 1 for relative value; 2 to make persistent
124    * (see GNUNET_STATISTICS_SETFLAG_*).
125    */
126   uint32_t flags GNUNET_PACKED;
127
128   /**
129    * Unique watch identification number (watch
130    * requests are enumerated in the order they
131    * are received, the first request having
132    * a wid of zero).
133    */
134   uint32_t wid GNUNET_PACKED;
135
136   /**
137    * Reserved (always 0).
138    */
139   uint32_t reserved GNUNET_PACKED;
140
141   /**
142    * Value. Note that if this is a relative value, it will
143    * be signed even though the type given here is unsigned.
144    */
145   uint64_t value GNUNET_PACKED;
146
147 };
148 GNUNET_NETWORK_STRUCT_END
149
150 #endif