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