aboutsummaryrefslogtreecommitdiff
path: root/src/nse/test_nse_multipeer.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-07-17 15:56:05 +0000
committerNathan S. Evans <evans@in.tum.de>2011-07-17 15:56:05 +0000
commitdd8821e8f0a432da4ec5fdacfa16644b9ed4c238 (patch)
treeae4725420924005405b2f74688a49ef1450dcd87 /src/nse/test_nse_multipeer.c
parent0265e48ab879a6593bc531de3bc3a82d2fbfef30 (diff)
downloadgnunet-dd8821e8f0a432da4ec5fdacfa16644b9ed4c238.tar.gz
gnunet-dd8821e8f0a432da4ec5fdacfa16644b9ed4c238.zip
print topology
Diffstat (limited to 'src/nse/test_nse_multipeer.c')
-rw-r--r--src/nse/test_nse_multipeer.c40
1 files changed, 39 insertions, 1 deletions
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;
59 59
60static unsigned int num_peers; 60static unsigned int num_peers;
61 61
62static unsigned int total_connections;
63
62static struct GNUNET_TESTING_PeerGroup *pg; 64static struct GNUNET_TESTING_PeerGroup *pg;
63 65
64/** 66/**
@@ -157,10 +159,46 @@ my_cb (void *cls,
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
158 "Peer Group started successfully, connecting to NSE service for each peer!\n"); 160 "Peer Group started successfully, connecting to NSE service for each peer!\n");
159#endif 161#endif
162 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", total_connections);
160 163
161 GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); 164 GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL);
162} 165}
163 166
167/**
168 * Prototype of a function that will be called whenever
169 * two daemons are connected by the testing library.
170 *
171 * @param cls closure
172 * @param first peer id for first daemon
173 * @param second peer id for the second daemon
174 * @param distance distance between the connected peers
175 * @param first_cfg config for the first daemon
176 * @param second_cfg config for the second daemon
177 * @param first_daemon handle for the first daemon
178 * @param second_daemon handle for the second daemon
179 * @param emsg error message (NULL on success)
180 */
181void connect_cb (void *cls,
182 const struct GNUNET_PeerIdentity *first,
183 const struct GNUNET_PeerIdentity *second,
184 uint32_t distance,
185 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
186 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
187 struct GNUNET_TESTING_Daemon *first_daemon,
188 struct GNUNET_TESTING_Daemon *second_daemon,
189 const char *emsg)
190{
191 char *second_id;
192
193 second_id = GNUNET_strdup(GNUNET_i2s(second));
194 if (emsg == NULL)
195 {
196 fprintf(stderr, "Connected %s -> %s\n", GNUNET_i2s(first), second_id);
197 total_connections++;
198 }
199}
200
201
164 202
165static void 203static void
166run (void *cls, 204run (void *cls,
@@ -186,7 +224,7 @@ run (void *cls,
186 pg = GNUNET_TESTING_peergroup_start(testing_cfg, 224 pg = GNUNET_TESTING_peergroup_start(testing_cfg,
187 peers_left, 225 peers_left,
188 TIMEOUT, 226 TIMEOUT,
189 NULL, 227 &connect_cb,
190 &my_cb, NULL, 228 &my_cb, NULL,
191 NULL); 229 NULL);
192 GNUNET_assert (pg != NULL); 230 GNUNET_assert (pg != NULL);