statistics.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2001-2014 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @author Christian Grothoff
  18. * @file statistics/statistics.h
  19. */
  20. #ifndef STATISTICS_H
  21. #define STATISTICS_H
  22. #include "gnunet_common.h"
  23. GNUNET_NETWORK_STRUCT_BEGIN
  24. /**
  25. * Statistics message. Contains how long the system is up
  26. * and one value.
  27. *
  28. * The struct is be followed by the service name and
  29. * name of the statistic, both 0-terminated.
  30. */
  31. struct GNUNET_STATISTICS_ReplyMessage
  32. {
  33. /**
  34. * Type: GNUNET_MESSAGE_TYPE_STATISTICS_VALUE
  35. */
  36. struct GNUNET_MessageHeader header;
  37. /**
  38. * Unique numerical identifier for the value (will
  39. * not change during the same client-session). Highest
  40. * bit will be set for persistent values (see
  41. * #GNUNET_STATISTICS_PERSIST_BIT).
  42. */
  43. uint32_t uid GNUNET_PACKED;
  44. /**
  45. * The value.
  46. */
  47. uint64_t value GNUNET_PACKED;
  48. };
  49. /**
  50. * Flag for the `struct GNUNET_STATISTICS_ReplyMessage` UID only.
  51. * Note that other messages use #GNUNET_STATISTICS_SETFLAG_PERSISTENT.
  52. */
  53. #define GNUNET_STATISTICS_PERSIST_BIT ((uint32_t) (1LLU<<31))
  54. /**
  55. * The value being set is an absolute change.
  56. */
  57. #define GNUNET_STATISTICS_SETFLAG_ABSOLUTE 0
  58. /**
  59. * The value being set is a relative change.
  60. */
  61. #define GNUNET_STATISTICS_SETFLAG_RELATIVE 1
  62. /**
  63. * The value being set is to be persistent (note that
  64. * this bit can be combined with #GNUNET_STATISTICS_SETFLAG_RELATIVE).
  65. * This value must not be used for the `uid` member of
  66. * `struct GNUNET_STATISTICS_ReplyMessage`!
  67. */
  68. #define GNUNET_STATISTICS_SETFLAG_PERSISTENT 2
  69. /**
  70. * Message to set a statistic. Followed
  71. * by the subsystem name and the name of
  72. * the statistic (each 0-terminated).
  73. */
  74. struct GNUNET_STATISTICS_SetMessage
  75. {
  76. /**
  77. * Type: #GNUNET_MESSAGE_TYPE_STATISTICS_SET
  78. */
  79. struct GNUNET_MessageHeader header;
  80. /**
  81. * 0 for absolute value, 1 for relative value; 2 to make persistent
  82. * (see GNUNET_STATISTICS_SETFLAG_*).
  83. */
  84. uint32_t flags GNUNET_PACKED;
  85. /**
  86. * Value. Note that if this is a relative value, it will
  87. * be signed even though the type given here is unsigned.
  88. */
  89. uint64_t value GNUNET_PACKED;
  90. };
  91. /**
  92. * Message transmitted if a watched value changes.
  93. */
  94. struct GNUNET_STATISTICS_WatchValueMessage
  95. {
  96. /**
  97. * Type: #GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE
  98. */
  99. struct GNUNET_MessageHeader header;
  100. /**
  101. * 0 for absolute value, 1 for relative value; 2 to make persistent
  102. * (see GNUNET_STATISTICS_SETFLAG_*).
  103. */
  104. uint32_t flags GNUNET_PACKED;
  105. /**
  106. * Unique watch identification number (watch
  107. * requests are enumerated in the order they
  108. * are received, the first request having
  109. * a wid of zero).
  110. */
  111. uint32_t wid GNUNET_PACKED;
  112. /**
  113. * Reserved (always 0).
  114. */
  115. uint32_t reserved GNUNET_PACKED;
  116. /**
  117. * Value. Note that if this is a relative value, it will
  118. * be signed even though the type given here is unsigned.
  119. */
  120. uint64_t value GNUNET_PACKED;
  121. };
  122. GNUNET_NETWORK_STRUCT_END
  123. #endif