gnunet_transport_monitor_service.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2009-2016 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. *
  19. * @file
  20. * Monitoring / diagnostics API for the transport service
  21. *
  22. * @defgroup transport TRANSPORT service
  23. * Communication with other peers
  24. *
  25. * @see [Documentation](https://gnunet.org/transport-service)
  26. *
  27. * @{
  28. */
  29. #ifndef GNUNET_TRANSPORT_MONITOR_SERVICE_H
  30. #define GNUNET_TRANSPORT_MONITOR_SERVICE_H
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #if 0 /* keep Emacsens' auto-indent happy */
  35. }
  36. #endif
  37. #endif
  38. #include "gnunet_util_lib.h"
  39. #include "gnunet_ats_transport_service.h"
  40. #include "gnunet_transport_communication_service.h"
  41. /**
  42. * Version number of the transport API.
  43. */
  44. #define GNUNET_TRANSPORT_MONITOR_VERSION 0x00000000
  45. /**
  46. * Information about another peer's address.
  47. */
  48. struct GNUNET_TRANSPORT_MonitorInformation
  49. {
  50. /**
  51. * Address we have for the peer, human-readable, 0-terminated, in UTF-8.
  52. */
  53. const char *address;
  54. /**
  55. * Network type of the address.
  56. */
  57. enum GNUNET_NetworkType nt;
  58. /**
  59. * Connection status.
  60. */
  61. enum GNUNET_TRANSPORT_ConnectionStatus cs;
  62. /**
  63. * Number of messages pending transmission for this @e address.
  64. */
  65. uint32_t num_msg_pending;
  66. /**
  67. * Number of bytes pending transmission for this @e address.
  68. */
  69. uint32_t num_bytes_pending;
  70. /**
  71. * When was this address last validated.
  72. */
  73. struct GNUNET_TIME_Absolute last_validation;
  74. /**
  75. * When does this address expire.
  76. */
  77. struct GNUNET_TIME_Absolute valid_until;
  78. /**
  79. * Time of the next validation operation.
  80. */
  81. struct GNUNET_TIME_Absolute next_validation;
  82. /**
  83. * Current estimate of the RTT.
  84. */
  85. struct GNUNET_TIME_Relative rtt;
  86. };
  87. /**
  88. * Function to call with information about a peer.
  89. *
  90. * If one_shot was set to #GNUNET_YES to iterate over all peers once,
  91. * a final call with NULL for peer and address will follow when done.
  92. * In this case state and timeout do not contain valid values.
  93. *
  94. * The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from
  95. * within this function!
  96. *
  97. *
  98. * @param cls closure
  99. * @param peer peer this update is about,
  100. * NULL if this is the final last callback for a iteration operation
  101. * @param mi monitoring data on the peer
  102. */
  103. typedef void
  104. (*GNUNET_TRANSPORT_MonitorCallback) (void *cls,
  105. const struct GNUNET_PeerIdentity *peer,
  106. const struct GNUNET_TRANSPORT_MonitorInformation *mi);
  107. /**
  108. * Handle for a #GNUNET_TRANSPORT_monitor() operation.
  109. */
  110. struct GNUNET_TRANSPORT_MonitorContext;
  111. /**
  112. * Return information about a specific peer or all peers currently known to
  113. * transport service once or in monitoring mode. To obtain information about
  114. * a specific peer, a peer identity can be passed. To obtain information about
  115. * all peers currently known to transport service, NULL can be passed as peer
  116. * identity.
  117. *
  118. * For each peer, the callback is called with information about the address used
  119. * to communicate with this peer, the state this peer is currently in and the
  120. * the current timeout for this state.
  121. *
  122. * Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one
  123. * more time with `NULL`. After this, the operation must no longer be
  124. * explicitly canceled.
  125. *
  126. * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
  127. * the peer_callback!
  128. *
  129. * @param cfg configuration to use
  130. * @param peer a specific peer identity to obtain information for,
  131. * NULL for all peers
  132. * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
  133. * #GNUNET_NO to monitor peers continuously
  134. * @param cb function to call with the results
  135. * @param cb_cls closure for @a mc
  136. */
  137. struct GNUNET_TRANSPORT_MonitorContext *
  138. GNUNET_TRANSPORT_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg,
  139. const struct GNUNET_PeerIdentity *peer,
  140. int one_shot,
  141. GNUNET_TRANSPORT_MonitorCallback cb,
  142. void *cb_cls);
  143. /**
  144. * Cancel request to monitor peers
  145. *
  146. * @param mc handle for the request to cancel
  147. */
  148. void
  149. GNUNET_TRANSPORT_monitor_cancel (struct GNUNET_TRANSPORT_MonitorContext *mc);
  150. #if 0 /* keep Emacsens' auto-indent happy */
  151. {
  152. #endif
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156. /* ifndef GNUNET_TRANSPORT_MONITOR_SERVICE_H */
  157. #endif
  158. /** @} */ /* end of group */
  159. /* end of gnunet_transport_monitor_service.h */