From: Nathan S. Evans Date: Sun, 17 Jul 2011 15:56:05 +0000 (+0000) Subject: print topology X-Git-Tag: initial-import-from-subversion-38251~17785 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dd8821e8f0a432da4ec5fdacfa16644b9ed4c238;p=oweals%2Fgnunet.git print topology --- diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c index 600e0c2f2..4edf53f20 100644 --- a/src/nse/test_nse_multipeer.c +++ b/src/nse/test_nse_multipeer.c @@ -59,6 +59,8 @@ static int peers_left; static unsigned int num_peers; +static unsigned int total_connections; + static struct GNUNET_TESTING_PeerGroup *pg; /** @@ -157,10 +159,46 @@ my_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully, connecting to NSE service for each peer!\n"); #endif + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", total_connections); GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); } +/** + * Prototype of a function that will be called whenever + * two daemons are connected by the testing library. + * + * @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 first_cfg config for the first daemon + * @param second_cfg config for the second daemon + * @param first_daemon handle for the first daemon + * @param second_daemon handle for the second daemon + * @param emsg error message (NULL on success) + */ +void connect_cb (void *cls, + const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, + uint32_t distance, + const struct GNUNET_CONFIGURATION_Handle *first_cfg, + const struct GNUNET_CONFIGURATION_Handle *second_cfg, + struct GNUNET_TESTING_Daemon *first_daemon, + struct GNUNET_TESTING_Daemon *second_daemon, + const char *emsg) +{ + char *second_id; + + second_id = GNUNET_strdup(GNUNET_i2s(second)); + if (emsg == NULL) + { + fprintf(stderr, "Connected %s -> %s\n", GNUNET_i2s(first), second_id); + total_connections++; + } +} + + static void run (void *cls, @@ -186,7 +224,7 @@ run (void *cls, pg = GNUNET_TESTING_peergroup_start(testing_cfg, peers_left, TIMEOUT, - NULL, + &connect_cb, &my_cb, NULL, NULL); GNUNET_assert (pg != NULL);