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