iterate topoogy header related stuff
authorNathan S. Evans <evans@in.tum.de>
Tue, 3 Aug 2010 08:22:59 +0000 (08:22 +0000)
committerNathan S. Evans <evans@in.tum.de>
Tue, 3 Aug 2010 08:22:59 +0000 (08:22 +0000)
src/include/gnunet_core_service.h
src/include/gnunet_protocols.h
src/include/gnunet_testing_lib.h

index 2434e3770c10bd2df24610dff5d415e5cb44661b..5dac1fa3855260ccf0c80b2cca71b462ab34e6fa 100644 (file)
@@ -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.
index 3f9f45395dfce848e9306a471d229dbea71a994e..e3f266e2542137ed914e87e4cbd05fd108c98176 100644 (file)
@@ -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.
index 04a2d8191e8411b976f68f86f34cd373698cbf49..479cb07e09c3eb068a0eaa97e8f894e175f3c93b 100644 (file)
@@ -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