From 7d86288c8819afc624d08cb88e3ed77ab05f541d Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Tue, 3 Aug 2010 08:22:59 +0000 Subject: [PATCH] iterate topoogy header related stuff --- src/include/gnunet_core_service.h | 14 ++++++++++++++ src/include/gnunet_protocols.h | 4 ++++ src/include/gnunet_testing_lib.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index 2434e3770..5dac1fa38 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -359,6 +359,20 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, void GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequestContext *irc); +/** + * Obtain statistics and/or change preferences for the given peer. + * + * @param sched scheduler to use + * @param cfg configuration to use + * @param peer_cb function to call with the peer information + * @param cb_cls closure for peer_cb + * @return GNUNET_OK if iterating, GNUNET_SYSERR on error + */ +int +GNUNET_CORE_iterate_peers (struct GNUNET_SCHEDULER_Handle *sched, + const struct GNUNET_CONFIGURATION_Handle *cfg, + GNUNET_CORE_ConnectEventHandler peer_cb, + void *cb_cls); /** * Handle for a transmission request. diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 3f9f45395..e3f266e25 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -360,6 +360,10 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT 75 +/** + * Request from client asking to call back with all connected peers. + */ +#define GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS 76 /** * Session key exchange between peers. diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 04a2d8191..479cb07e0 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -363,6 +363,23 @@ typedef void (*GNUNET_TESTING_NotifyConnection)(void *cls, struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg); +/** + * Prototype of a callback function indicating that two peers + * are currently connected. + * + * @param cls closure + * @param first peer id for first daemon + * @param second peer id for the second daemon + * @param distance distance between the connected peers + * @param emsg error message (NULL on success) + */ +typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls, + const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, + struct GNUNET_TIME_Relative latency, + uint32_t distance, + const char *emsg); + /** * Starts a GNUnet daemon. GNUnet must be installed on the target * system and available in the PATH. The machine must furthermore be @@ -742,6 +759,17 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, enum GNUNET_TESTING_Topology restrict_topology, char *restrict_transports); +/** + * Iterate over all (running) peers in the peer group, retrieve + * all connections that each currently has. + * + * @param pg the peer group we are concerned with + * @param cb callback for topology information + * @param cls closure for callback + */ +void +GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_NotifyTopology cb, void *cls); + /** * There are many ways to connect peers that are supported by this function. * To connect peers in the same topology that was created via the -- 2.25.1