aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/statistics.h
blob: 49a4f06cacef4b2380f0ed488d4739adf052998a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
     This file is part of GNUnet.
     Copyright (C) 2001-2014 Christian Grothoff (and other contributing authors)

     GNUnet is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 3, or (at your
     option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     Boston, MA 02110-1301, USA.
*/

/**
 * @author Christian Grothoff
 * @file statistics/statistics.h
 */
#ifndef STATISTICS_H
#define STATISTICS_H

#include "gnunet_common.h"


GNUNET_NETWORK_STRUCT_BEGIN

/**
 * Statistics message. Contains how long the system is up
 * and one value.
 *
 * The struct is be followed by the service name and
 * name of the statistic, both 0-terminated.
 */
struct GNUNET_STATISTICS_ReplyMessage
{
  /**
   * Type:  GNUNET_MESSAGE_TYPE_STATISTICS_VALUE
   */
  struct GNUNET_MessageHeader header;

  /**
   * Unique numerical identifier for the value (will
   * not change during the same client-session).  Highest
   * bit will be set for persistent values (see
   * #GNUNET_STATISTICS_PERSIST_BIT).
   */
  uint32_t uid GNUNET_PACKED;

  /**
   * The value.
   */
  uint64_t value GNUNET_PACKED;

};

/**
 * Flag for the `struct GNUNET_STATISTICS_ReplyMessage` UID only.
 * Note that other messages use #GNUNET_STATISTICS_SETFLAG_PERSISTENT.
 */
#define GNUNET_STATISTICS_PERSIST_BIT (1<<31)

/**
 * The value being set is an absolute change.
 */
#define GNUNET_STATISTICS_SETFLAG_ABSOLUTE 0

/**
 * The value being set is a relative change.
 */
#define GNUNET_STATISTICS_SETFLAG_RELATIVE 1

/**
 * The value being set is to be persistent (note that
 * this bit can be combined with #GNUNET_STATISTICS_SETFLAG_RELATIVE).
 * This value must not be used for the `uid` member of
 * `struct GNUNET_STATISTICS_ReplyMessage`!
 */
#define GNUNET_STATISTICS_SETFLAG_PERSISTENT 2


/**
 * Message to set a statistic.  Followed
 * by the subsystem name and the name of
 * the statistic (each 0-terminated).
 */
struct GNUNET_STATISTICS_SetMessage
{
  /**
   * Type: #GNUNET_MESSAGE_TYPE_STATISTICS_SET
   */
  struct GNUNET_MessageHeader header;

  /**
   * 0 for absolute value, 1 for relative value; 2 to make persistent
   * (see GNUNET_STATISTICS_SETFLAG_*).
   */
  uint32_t flags GNUNET_PACKED;

  /**
   * Value. Note that if this is a relative value, it will
   * be signed even though the type given here is unsigned.
   */
  uint64_t value GNUNET_PACKED;

};


/**
 * Message transmitted if a watched value changes.
 */
struct GNUNET_STATISTICS_WatchValueMessage
{
  /**
   * Type: #GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE
   */
  struct GNUNET_MessageHeader header;

  /**
   * 0 for absolute value, 1 for relative value; 2 to make persistent
   * (see GNUNET_STATISTICS_SETFLAG_*).
   */
  uint32_t flags GNUNET_PACKED;

  /**
   * Unique watch identification number (watch
   * requests are enumerated in the order they
   * are received, the first request having
   * a wid of zero).
   */
  uint32_t wid GNUNET_PACKED;

  /**
   * Reserved (always 0).
   */
  uint32_t reserved GNUNET_PACKED;

  /**
   * Value. Note that if this is a relative value, it will
   * be signed even though the type given here is unsigned.
   */
  uint64_t value GNUNET_PACKED;

};
GNUNET_NETWORK_STRUCT_END

#endif