diff options
Diffstat (limited to 'src/transport/test_transport_api_bidirectional_connect.c')
-rw-r--r-- | src/transport/test_transport_api_bidirectional_connect.c | 87 |
1 files changed, 54 insertions, 33 deletions
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c index 5c9ae36fe..f7f284a9a 100644 --- a/src/transport/test_transport_api_bidirectional_connect.c +++ b/src/transport/test_transport_api_bidirectional_connect.c | |||
@@ -185,20 +185,24 @@ notify_ready (void *cls, size_t size, void *buf) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | GNUNET_assert (size >= 256); | 187 | GNUNET_assert (size >= 256); |
188 | hdr = buf; | ||
189 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
190 | hdr->type = htons (MTYPE); | ||
188 | 191 | ||
189 | if (buf != NULL) | ||
190 | { | 192 | { |
191 | hdr = buf; | 193 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
192 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 194 | |
193 | hdr->type = htons (MTYPE); | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
196 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
197 | p2->no, | ||
198 | ps, | ||
199 | ntohs (hdr->type), | ||
200 | ntohs (hdr->size), | ||
201 | p->no, | ||
202 | GNUNET_i2s (&p->id)); | ||
203 | GNUNET_free (ps); | ||
194 | } | 204 | } |
195 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
196 | 205 | ||
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
198 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
199 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
200 | GNUNET_i2s (&p->id)); | ||
201 | GNUNET_free (ps); | ||
202 | return sizeof (struct GNUNET_MessageHeader); | 206 | return sizeof (struct GNUNET_MessageHeader); |
203 | } | 207 | } |
204 | 208 | ||
@@ -229,7 +233,6 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
229 | static int c; | 233 | static int c; |
230 | 234 | ||
231 | c++; | 235 | c++; |
232 | GNUNET_assert (NULL != cls); | ||
233 | struct PeerContext *p = cls; | 236 | struct PeerContext *p = cls; |
234 | struct PeerContext *t = NULL; | 237 | struct PeerContext *t = NULL; |
235 | 238 | ||
@@ -239,12 +242,17 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
239 | t = p2; | 242 | t = p2; |
240 | GNUNET_assert (t != NULL); | 243 | GNUNET_assert (t != NULL); |
241 | 244 | ||
242 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 245 | { |
243 | 246 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | |
244 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 247 | |
245 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
246 | t->no, GNUNET_i2s (peer)); | 249 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
247 | GNUNET_free (ps); | 250 | p->no, |
251 | ps, | ||
252 | t->no, | ||
253 | GNUNET_i2s (peer)); | ||
254 | GNUNET_free (ps); | ||
255 | } | ||
248 | } | 256 | } |
249 | 257 | ||
250 | 258 | ||
@@ -252,14 +260,17 @@ static void | |||
252 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 260 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
253 | { | 261 | { |
254 | struct PeerContext *p = cls; | 262 | struct PeerContext *p = cls; |
255 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
256 | |||
257 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
258 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
259 | p->no, ps, | ||
260 | GNUNET_i2s (peer)); | ||
261 | GNUNET_free (ps); | ||
262 | 263 | ||
264 | { | ||
265 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
266 | |||
267 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
268 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
269 | p->no, | ||
270 | ps, | ||
271 | GNUNET_i2s (peer)); | ||
272 | GNUNET_free (ps); | ||
273 | } | ||
263 | if (NULL != send_task) | 274 | if (NULL != send_task) |
264 | { | 275 | { |
265 | GNUNET_SCHEDULER_cancel(send_task); | 276 | GNUNET_SCHEDULER_cancel(send_task); |
@@ -277,7 +288,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
277 | static void | 288 | static void |
278 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 289 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
279 | { | 290 | { |
280 | static int connected = GNUNET_NO; | 291 | static int connected = GNUNET_NO; |
292 | |||
281 | if ((cls == cc1) && (NULL != cc2)) | 293 | if ((cls == cc1) && (NULL != cc2)) |
282 | { | 294 | { |
283 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); | 295 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); |
@@ -290,14 +302,23 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
290 | cc2 = NULL; | 302 | cc2 = NULL; |
291 | 303 | ||
292 | if (connected > 0) | 304 | if (connected > 0) |
293 | return; | 305 | return; |
294 | connected ++; | 306 | connected++; |
295 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 307 | |
296 | 308 | { | |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 309 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
298 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 310 | |
299 | GNUNET_free (p1_c); | 311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
300 | send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL); | 312 | "Peers connected: %u (%s) <-> %u (%s)\n", |
313 | p1->no, | ||
314 | p1_c, | ||
315 | p2->no, | ||
316 | GNUNET_i2s (&p2->id)); | ||
317 | GNUNET_free (p1_c); | ||
318 | } | ||
319 | send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
320 | &sendtask, | ||
321 | NULL); | ||
301 | } | 322 | } |
302 | 323 | ||
303 | 324 | ||